b0c9eb90d5e92ae69244e2e7a18df87cc99bc34a
[oweals/cde.git] / cde / lib / DtSvc / DtUtil2 / FileUtil.h
1 /*
2  * File:         FileUtil.h $XConsortium: FileUtil.h /main/4 1995/10/26 15:21:50 rswiston $
3  * Language:     C
4  *
5  * (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
6  *
7  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
8  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
9  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
10  * (c) Copyright 1993, 1994 Novell, Inc.                                *
11  */
12
13 #ifndef _FileUtil_h
14 #define _FileUtil_h
15
16 extern int _DtCreateDirs( char *path,
17                          int mode) ;
18
19 /******************
20  *
21  * Function Name:  _DtCreateDirs
22  *
23  * Description:
24  *
25  *      This function is passed a directory path to create and the mode
26  *      for the directory.  It will create any of the parent directories 
27  *      on the path that do not already exist.
28  *
29  *      This function may fail if any of the directories on the path already
30  *      exist and are not writable.  If some component of the path already
31  *      exists and is not a directory, a failure will be returned.  
32  *
33  *      If some component of the path exists as a directory but does not have 
34  *      the specified mode, this will NOT cause a failure to be returned.
35  *      This implies that if this function is called to create a writeable
36  *      directory, it is possible for the function to return successfully
37  *      but the directory may not actually be writable.
38  *
39  * Synopsis:
40  *
41  *      status = _DtCreateDirs (path, mode);
42  *
43  *      int status;             Returns 0 on success and -1 on failure.
44  *      char *path;             The directory path to create.
45  *      int mode;               The file mode for setting any directories
46  *                              that are created.
47  *
48  ******************/
49
50
51 extern int _DtIsOpenableDir( char *path) ;
52
53 /******************
54  *
55  * Function Name:  _DtIsOpenableDir
56  *
57  * Description:
58  *
59  *      This function takes a path as an argument and determines whether
60  *      the path is a directory that can be opened.  This function returns
61  *      "1" if the path is an openable directory and "0" if it is not.
62  *
63  *      The path can be in the Softbench "context" form of "host:/path/dir".
64  *
65  * Synopsis:
66  *
67  *      status = _DtIsOpenableDir (cpath)
68  *
69  *      int status;             Returns 1 for openable directories, 
70  *                              0 otherwise.
71  *      char *cpath;            The directory name to test.
72  *
73  ******************/
74
75
76 extern int 
77 _DtIsOpenableDirContext(
78         char *path,
79         char **ret_path ) ;
80
81 /******************
82  *
83  * Function Name:  _DtIsOpenableDirContext
84  *
85  * Description:
86  *
87  *      This function takes a path as an argument and determines whether
88  *      the path is a directory that can be opened.  This function returns
89  *      "1" if the path is an openable directory and "0" if it is not.
90  *      In addition, if the calling function passes in another pointer,
91  *      we will return the internal representation for the path.
92  *
93  *      The path can be in the Softbench "context" form of "host:/path/dir".
94  *
95  * Synopsis:
96  *
97  *      status = _DtIsOpenableDirContext (cpath, ret_ptr)
98  *
99  *      int status;             Returns 1 for openable directories, 
100  *                              0 otherwise.
101  *      char *cpath;            The directory name to test.
102  *      char ** ret_ptr;        Where to place internal format.
103  *
104  ******************/
105
106
107 extern char * _DtReaddirLstat( 
108                         char *dir_name,
109                         DIR *dirp,
110                         struct stat *st_buf) ;
111
112 /******************
113  *
114  * Function Name:  _DtReaddirLstat
115  *
116  * Description:
117  *
118  *      This function reads the next entry out of a directory that has
119  *      been opened with opendir and returns lstat information on it.  
120  *      For more information on reading a directory, see directory(3C).
121  *      For more information on lstat information, see stat(2).
122  *
123  *      This function returns a pointer to the full pathname of the directory
124  *      entry.  This memory is owned by this function and must not be 
125  *      freed.  If the caller wants to keep the filename, it must make its
126  *      own copy.  When the end of the directory is encountered, NULL is
127  *      returned.
128  *
129  * Synopsis:
130  *
131  *      dir_entry = _DtReaddirLstat (dir_name, dirp, st_buf);
132  *
133  *      char *dir_entry;        The name of the current entry within the
134  *                              directory.
135  *
136  *      char *dir_name;         The full path name of the directory.
137  *
138  *      DIR *dirp;              A pointer to the directory [obtained from
139  *                              opendir(3C)].
140  *
141  *      struct stat *st_buf;    The lstat(2) information.
142  *
143  ******************/
144
145 #endif /* _FileUtil_h */
146
147 /* DON'T ADD ANYTHING AFTER THIS #endif */