1 mike 1.1 //BEGIN_LICENSE
2 //
3 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 // DEALINGS IN THE SOFTWARE.
19 //
20 //END_LICENSE
21 //BEGIN_HISTORY
22 mike 1.1 //
23 // Author: Michael E. Brasher
24 //
|
60 mike 1.3 }
61
62 Boolean System::exists(const char* path)
63 {
64 return access(path, F_OK) == 0;
65 }
66
67 Boolean FileSystem::canRead(const char* path)
68 {
69 return access(path, R_OK) == 0;
70 }
71
72 Boolean System::canWrite(const char* path)
73 {
74 return _access(path, W_OK) == 0;
75 }
76
77 Boolean System::getCurrentDirectory(char* path, Uint32 size)
78 {
79 return getcwd(path, size) != NULL;
80 }
81 mike 1.3
82 Boolean System::isDirectory(const char* path)
83 {
84 struct stat st;
85
86 if (stat(p.getPointer(), &st) != 0)
87 return false;
88
89 return S_ISDIR(st.st_mode);
90 }
91
92 Boolean System::changeDirectory(const char* path)
93 {
94 return chdir(path) == 0;
95 }
96
97 Boolean System::makeDirectory(const char* path)
98 {
99 return mkdir(path, 0777) == 0;
100 }
101
102 mike 1.3 Boolean System::getFileSize(const char* path, Uint32& size)
103 {
104 struct stat st;
105
106 if (stat(path, &st) != 0)
107 return false;
108
109 size = st.st_size;
110 return true;
111 }
112
113 Boolean System::removeDirectory(const char* path)
114 {
115 return rmdir(path) == 0;
116 }
117
118 Boolean System::removeFile(const char* path)
119 {
120 return unlink(path) == 0;
121 }
122
123 mike 1.3 Boolean System::renameFile(const char* oldPath, const char* newPath)
124 {
125 if (link(oldPath, newPath) != 0)
126 return false;
127
128 return unlink(oldPath) == 0;
|
131 mike 1.4 DynamicLibraryHandle System::loadDynamicLibrary(const char* fileName)
132 {
133 return DynamicLibraryHandle(dlopen(fileName, 0));
134 }
135
136 DynamicSymbolHandle System::loadDynamicSymbol(
137 DynamicLibraryHandle libraryHandle,
138 const char* symbolName)
139 {
140 return DynamicSymbolHandle(dlsym(libraryHandle, (char*)symbolName));
141 }
142
|