]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. | |
3 | * | |
4 | * This file is part of Jam - see jam.c for Copyright information. | |
5 | */ | |
6 | ||
7 | /* This file is ALSO: | |
8 | * Copyright 2001-2004 David Abrahams. | |
9 | * Distributed under the Boost Software License, Version 1.0. | |
1e59de90 | 10 | * (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) |
7c673cae FG |
11 | */ |
12 | ||
13 | /* | |
14 | * filesys.h - OS specific file routines | |
15 | */ | |
16 | ||
17 | #ifndef FILESYS_DWA20011025_H | |
18 | #define FILESYS_DWA20011025_H | |
19 | ||
92f5a8d4 | 20 | #include "config.h" |
7c673cae FG |
21 | #include "hash.h" |
22 | #include "lists.h" | |
23 | #include "object.h" | |
24 | #include "pathsys.h" | |
25 | #include "timestamp.h" | |
26 | ||
20effc67 TL |
27 | #include <string> |
28 | ||
7c673cae FG |
29 | |
30 | typedef struct file_info_t | |
31 | { | |
32 | OBJECT * name; | |
33 | char is_file; | |
34 | char is_dir; | |
35 | char exists; | |
36 | timestamp time; | |
37 | LIST * files; | |
38 | } file_info_t; | |
39 | ||
40 | typedef struct file_item FILEITEM; | |
41 | struct file_item | |
42 | { | |
92f5a8d4 | 43 | file_info_t * value; /* expected to be equivalent with &FILEITEM */ |
7c673cae FG |
44 | FILEITEM * next; |
45 | }; | |
46 | ||
47 | typedef struct file_list | |
48 | { | |
49 | FILEITEM * head; | |
50 | FILEITEM * tail; | |
51 | int size; | |
52 | } FILELIST; | |
53 | ||
54 | typedef file_info_t * * FILELISTITER; /* also &FILEITEM equivalent */ | |
55 | ||
56 | ||
57 | typedef struct file_archive_info_t | |
58 | { | |
11fdf7f2 | 59 | OBJECT * name; |
7c673cae FG |
60 | file_info_t * file; |
61 | FILELIST * members; | |
62 | } file_archive_info_t; | |
63 | ||
64 | ||
65 | typedef void (*archive_scanback)( void * closure, OBJECT * path, LIST * symbols, | |
66 | int found, timestamp const * const ); | |
67 | typedef void (*scanback)( void * closure, OBJECT * path, int found, | |
68 | timestamp const * const ); | |
69 | ||
70 | ||
71 | void file_archscan( char const * arch, scanback func, void * closure ); | |
72 | void file_archivescan( OBJECT * path, archive_scanback func, void * closure ); | |
73 | void file_build1( PATHNAME * const f, string * file ) ; | |
74 | void file_dirscan( OBJECT * dir, scanback func, void * closure ); | |
75 | file_info_t * file_info( OBJECT * const path, int * found ); | |
76 | int file_is_file( OBJECT * const path ); | |
77 | int file_mkdir( char const * const path ); | |
78 | file_info_t * file_query( OBJECT * const path ); | |
79 | void file_remove_atexit( OBJECT * const path ); | |
80 | void file_supported_fmt_resolution( timestamp * const ); | |
81 | int file_time( OBJECT * const path, timestamp * const ); | |
82 | ||
20effc67 TL |
83 | namespace b2 { namespace filesys { |
84 | ||
85 | inline bool is_file(const std::string &path) | |
86 | { | |
87 | OBJECT * path_o = object_new(path.c_str()); | |
88 | bool result = file_is_file(path_o) == 1; | |
89 | object_free(path_o); | |
90 | return result; | |
91 | } | |
92 | ||
93 | }} | |
94 | ||
7c673cae FG |
95 | |
96 | /* Archive/library file support */ | |
97 | file_archive_info_t * file_archive_info( OBJECT * const path, int * found ); | |
98 | file_archive_info_t * file_archive_query( OBJECT * const path ); | |
99 | ||
100 | /* FILELIST linked-list */ | |
101 | FILELIST * filelist_new( OBJECT * path ); | |
102 | FILELIST * filelist_push_back( FILELIST * list, OBJECT * path ); | |
103 | FILELIST * filelist_push_front( FILELIST * list, OBJECT * path ); | |
104 | FILELIST * filelist_pop_front( FILELIST * list ); | |
105 | int filelist_length( FILELIST * list ); | |
106 | void filelist_free( FILELIST * list ); | |
107 | ||
108 | FILELISTITER filelist_begin( FILELIST * list ); | |
109 | FILELISTITER filelist_end( FILELIST * list ); | |
110 | FILELISTITER filelist_next( FILELISTITER it ); | |
111 | file_info_t * filelist_item( FILELISTITER it ); | |
112 | file_info_t * filelist_front( FILELIST * list ); | |
113 | file_info_t * filelist_back( FILELIST * list ); | |
114 | ||
b32b8144 FG |
115 | int filelist_empty( FILELIST * list ); |
116 | ||
7c673cae FG |
117 | #define FL0 ((FILELIST *)0) |
118 | ||
119 | ||
120 | /* Internal utility worker functions. */ | |
121 | void file_query_posix_( file_info_t * const ); | |
122 | ||
123 | void file_done(); | |
124 | ||
125 | #endif |