CARMA C++
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
pathname.h
1
#ifndef pathname_h
2
#define pathname_h
3
4
#include <time.h>
5
6
/*
7
* Construct a pathname from a directory component and/or a filename
8
* component after replacing any initial ~ or ~user with the
9
* corresponding home directory name.
10
*
11
* The path will be constructed from the dir[] and name[] strings
12
* as follows:
13
*
14
* 1. If dir[0] == ~ or dir=="" and name[0] == ~, then the ~ or ~user
15
* will be replaced by the home directory of the user (or that of
16
* the current effective user id if no username follows the ~).
17
*
18
* 2. If (dir != "" && dir[strlen(dir)-1] != '/' && name[0] != '/') then
19
* an sprintf format of "%s/%s" will be used to concatenate the
20
* strings. Otherwise "%s%s" will be used.
21
*
22
* If separate dir[] and name[] strings are not convenient send dir="".
23
*
24
* This function returns memory acquired from malloc() (NULL on error).
25
* It is the caller's responsibility to free this memory when it is no
26
* longer required.
27
*/
28
char
*new_pathname(
char
*dir,
char
*name);
29
30
/*
31
* Enumerate the classes of files that can be distinguished by
32
* test_pathname().
33
*/
34
typedef
enum
{
35
PATH_IS_PIPE,
/* Test whether the path refers to a named pipe */
36
PATH_IS_DIR,
/* Test whether the path refers to a directory */
37
PATH_IS_REG,
/* Test whether the path refers to an ordinary file */
38
PATH_ANY
/* Allow any file type with the specified permissions */
39
} PathType;
40
41
/*
42
* Enumerate an orthogonal set of file permissions that can be tested for
43
* by test_pathname().
44
*/
45
typedef
enum
{
46
PATH_READ = 1,
/* Test if the file is readable */
47
PATH_WRITE = 2,
/* Test if the file is writable */
48
PATH_EXE = 4,
/* Test if the file is executable */
49
PATH_OK = 8
/* Test if the file exists, regardless of permissions */
50
} PathRights;
51
52
/*
53
* Test whether a pathname refers to a file with given attributes, where
54
* the 'rights' argument is a bitwise OR of one or more of the above
55
* PathRights enumerators.
56
* Note that VxWorks doesn't have the access() system call, so this
57
* can't easily be implemented under VxWorks.
58
*/
59
#ifndef VXW
60
char
*test_pathname(
char
*path, PathType type,
unsigned
rights);
61
#endif
62
63
/*
64
* Return the standard unix access times of a given file.
65
*/
66
char
*path_access_times(
char
*path, time_t *atime, time_t *mtime,
67
time_t *ctime);
68
69
/*
70
* Set the current working directory of the calling process.
71
*/
72
int
set_working_directory(
char
*path);
73
74
/*
75
* Get a dynamically allocated copy of the pathname of the current working
76
* directory of the calling process.
77
*/
78
char
*get_working_directory(
void
);
79
80
/*
81
* Get a dynamically allocated copy of the name of the current host.
82
*/
83
char
*get_name_of_host(
void
);
84
85
#endif
carma
szaarrayutils
pathname.h
Generated by
1.8.5