blob: d3e4d96a83ef636d165308f594468b8d1743a47b [file] [log] [blame]
Reid Spencerb89a2232004-08-25 06:20:07 +00001//===- llvm/System/Unix/Path.cpp - Unix Path Implementation -----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Reid Spencer and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the Unix specific portion of the Path class.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15//=== WARNING: Implementation here must contain only generic UNIX code that
Reid Spencer8e665952004-08-29 05:24:01 +000016//=== is guaranteed to work on *all* UNIX variants.
Reid Spencerb89a2232004-08-25 06:20:07 +000017//===----------------------------------------------------------------------===//
18
Reid Spencer551ccae2004-09-01 22:55:40 +000019#include <llvm/Config/config.h>
Reid Spencerbe31d2a2004-11-16 17:14:08 +000020#include <llvm/Config/alloca.h>
Reid Spencerb89a2232004-08-25 06:20:07 +000021#include "Unix.h"
22#include <sys/stat.h>
23#include <fcntl.h>
Reid Spencereaf18152004-11-14 22:08:36 +000024#include <utime.h>
25#include <dirent.h>
Reid Spencerb89a2232004-08-25 06:20:07 +000026
Reid Spencer8e665952004-08-29 05:24:01 +000027namespace llvm {
28using namespace sys;
Reid Spencerb89a2232004-08-25 06:20:07 +000029
Reid Spencer8e665952004-08-29 05:24:01 +000030Path::Path(std::string unverified_path)
31 : path(unverified_path)
Reid Spencerb89a2232004-08-25 06:20:07 +000032{
Reid Spencer8e665952004-08-29 05:24:01 +000033 if (unverified_path.empty())
34 return;
Reid Spencer07adb282004-11-05 22:15:36 +000035 if (this->isValid())
Reid Spencer8e665952004-08-29 05:24:01 +000036 return;
37 // oops, not valid.
38 path.clear();
39 ThrowErrno(unverified_path + ": path is not valid");
Reid Spencerb89a2232004-08-25 06:20:07 +000040}
41
Reid Spencer8e665952004-08-29 05:24:01 +000042Path
43Path::GetRootDirectory() {
44 Path result;
Reid Spencer07adb282004-11-05 22:15:36 +000045 result.setDirectory("/");
Reid Spencer8e665952004-08-29 05:24:01 +000046 return result;
47}
48
Reid Spencer74e72612004-09-14 00:16:39 +000049static inline bool IsLibrary(Path& path, const std::string& basename) {
Reid Spencer07adb282004-11-05 22:15:36 +000050 if (path.appendFile(std::string("lib") + basename)) {
51 if (path.appendSuffix(Path::GetDLLSuffix()) && path.readable())
Reid Spencer74e72612004-09-14 00:16:39 +000052 return true;
Reid Spencer07adb282004-11-05 22:15:36 +000053 else if (path.elideSuffix() && path.appendSuffix("a") && path.readable())
Reid Spencer74e72612004-09-14 00:16:39 +000054 return true;
Reid Spencer07adb282004-11-05 22:15:36 +000055 else if (path.elideSuffix() && path.appendSuffix("o") && path.readable())
Reid Spencer74e72612004-09-14 00:16:39 +000056 return true;
Reid Spencer07adb282004-11-05 22:15:36 +000057 else if (path.elideSuffix() && path.appendSuffix("bc") && path.readable())
Reid Spencer0cc2d0a2004-09-16 16:36:10 +000058 return true;
Reid Spencer07adb282004-11-05 22:15:36 +000059 } else if (path.elideFile() && path.appendFile(basename)) {
60 if (path.appendSuffix(Path::GetDLLSuffix()) && path.readable())
Reid Spencer74e72612004-09-14 00:16:39 +000061 return true;
Reid Spencer07adb282004-11-05 22:15:36 +000062 else if (path.elideSuffix() && path.appendSuffix("a") && path.readable())
Reid Spencer74e72612004-09-14 00:16:39 +000063 return true;
Reid Spencer07adb282004-11-05 22:15:36 +000064 else if (path.elideSuffix() && path.appendSuffix("o") && path.readable())
Reid Spencer74e72612004-09-14 00:16:39 +000065 return true;
Reid Spencer07adb282004-11-05 22:15:36 +000066 else if (path.elideSuffix() && path.appendSuffix("bc") && path.readable())
Reid Spencer0cc2d0a2004-09-16 16:36:10 +000067 return true;
Reid Spencer74e72612004-09-14 00:16:39 +000068 }
69 path.clear();
70 return false;
71}
72
73Path
74Path::GetLibraryPath(const std::string& basename,
75 const std::vector<std::string>& LibPaths) {
76 Path result;
77
78 // Try the paths provided
79 for (std::vector<std::string>::const_iterator I = LibPaths.begin(),
80 E = LibPaths.end(); I != E; ++I ) {
Reid Spencer07adb282004-11-05 22:15:36 +000081 if (result.setDirectory(*I) && IsLibrary(result,basename))
Reid Spencer74e72612004-09-14 00:16:39 +000082 return result;
83 }
84
Reid Spencer0cc2d0a2004-09-16 16:36:10 +000085 // Try the LLVM lib directory in the LLVM install area
Reid Spencer07adb282004-11-05 22:15:36 +000086 if (result.setDirectory(LLVM_LIBDIR) && IsLibrary(result,basename))
Reid Spencer0cc2d0a2004-09-16 16:36:10 +000087 return result;
88
Reid Spencer74e72612004-09-14 00:16:39 +000089 // Try /usr/lib
Reid Spencer07adb282004-11-05 22:15:36 +000090 if (result.setDirectory("/usr/lib/") && IsLibrary(result,basename))
Reid Spencer74e72612004-09-14 00:16:39 +000091 return result;
92
93 // Try /lib
Reid Spencer07adb282004-11-05 22:15:36 +000094 if (result.setDirectory("/lib/") && IsLibrary(result,basename))
Reid Spencer74e72612004-09-14 00:16:39 +000095 return result;
96
97 // Can't find it, give up and return invalid path.
98 result.clear();
99 return result;
100}
101
Reid Spencer8e665952004-08-29 05:24:01 +0000102Path
103Path::GetSystemLibraryPath1() {
104 return Path("/lib/");
105}
106
107Path
108Path::GetSystemLibraryPath2() {
109 return Path("/usr/lib/");
110}
111
112Path
113Path::GetLLVMDefaultConfigDir() {
114 return Path("/etc/llvm/");
115}
116
117Path
118Path::GetLLVMConfigDir() {
119 Path result;
Reid Spencer07adb282004-11-05 22:15:36 +0000120 if (result.setDirectory(LLVM_ETCDIR))
Reid Spencer8e665952004-08-29 05:24:01 +0000121 return result;
122 return GetLLVMDefaultConfigDir();
123}
124
125Path
126Path::GetUserHomeDirectory() {
127 const char* home = getenv("HOME");
128 if (home) {
129 Path result;
Reid Spencer07adb282004-11-05 22:15:36 +0000130 if (result.setDirectory(home))
Reid Spencer8e665952004-08-29 05:24:01 +0000131 return result;
132 }
133 return GetRootDirectory();
134}
135
136bool
Reid Spencer07adb282004-11-05 22:15:36 +0000137Path::isFile() const {
138 return (isValid() && path[path.length()-1] != '/');
Reid Spencer1b554b42004-09-11 04:55:08 +0000139}
140
141bool
Reid Spencer07adb282004-11-05 22:15:36 +0000142Path::isDirectory() const {
143 return (isValid() && path[path.length()-1] == '/');
Reid Spencer1b554b42004-09-11 04:55:08 +0000144}
145
146std::string
Reid Spencer07adb282004-11-05 22:15:36 +0000147Path::getBasename() const {
Reid Spencer1b554b42004-09-11 04:55:08 +0000148 // Find the last slash
149 size_t slash = path.rfind('/');
150 if (slash == std::string::npos)
151 slash = 0;
152 else
153 slash++;
154
155 return path.substr(slash, path.rfind('.'));
156}
157
Reid Spencer07adb282004-11-05 22:15:36 +0000158bool Path::hasMagicNumber(const std::string &Magic) const {
Reid Spencer1b554b42004-09-11 04:55:08 +0000159 size_t len = Magic.size();
Reid Spencerbe31d2a2004-11-16 17:14:08 +0000160 assert(len < 1024 && "Request for magic string too long");
161 char* buf = (char*) alloca(1 + len);
162 int fd = ::open(path.c_str(),O_RDONLY);
163 if (fd < 0)
164 return false;
165 if (0 != ::read(fd, buf, len))
166 return false;
167 close(fd);
Reid Spencer1b554b42004-09-11 04:55:08 +0000168 buf[len] = '\0';
169 return Magic == buf;
170}
171
Reid Spencereaf18152004-11-14 22:08:36 +0000172bool Path::getMagicNumber(std::string& Magic, unsigned len) const {
173 if (!isFile())
174 return false;
Reid Spencerbe31d2a2004-11-16 17:14:08 +0000175 assert(len < 1024 && "Request for magic string too long");
176 char* buf = (char*) alloca(1 + len);
177 int fd = ::open(path.c_str(),O_RDONLY);
178 if (fd < 0)
179 return false;
Reid Spencer86ac2dc2004-12-02 09:09:48 +0000180 ssize_t bytes_read = ::read(fd, buf, len);
181 ::close(fd);
182 if (ssize_t(len) != bytes_read) {
183 Magic.clear();
Reid Spencerbe31d2a2004-11-16 17:14:08 +0000184 return false;
Reid Spencer86ac2dc2004-12-02 09:09:48 +0000185 }
186 Magic.assign(buf,len);
Reid Spencereaf18152004-11-14 22:08:36 +0000187 return true;
188}
189
Reid Spencer1b554b42004-09-11 04:55:08 +0000190bool
Reid Spencer07adb282004-11-05 22:15:36 +0000191Path::isBytecodeFile() const {
Reid Spencer9195f372004-11-09 20:26:31 +0000192 char buffer[ 4];
193 buffer[0] = 0;
Reid Spencer1fce0912004-12-11 00:14:15 +0000194 int fd = ::open(path.c_str(),O_RDONLY);
195 if (fd < 0)
196 return false;
197 ssize_t bytes_read = ::read(fd, buffer, 4);
198 ::close(fd);
199 if (4 != bytes_read)
200 return false;
Reid Spencereaf18152004-11-14 22:08:36 +0000201
202 return (buffer[0] == 'l' && buffer[1] == 'l' && buffer[2] == 'v' &&
203 (buffer[3] == 'c' || buffer[3] == 'm'));
Reid Spencer1b554b42004-09-11 04:55:08 +0000204}
205
206bool
Reid Spencer07adb282004-11-05 22:15:36 +0000207Path::isArchive() const {
Reid Spencer1b554b42004-09-11 04:55:08 +0000208 if (readable()) {
Reid Spencer07adb282004-11-05 22:15:36 +0000209 return hasMagicNumber("!<arch>\012");
Reid Spencer1b554b42004-09-11 04:55:08 +0000210 }
211 return false;
212}
213
214bool
Reid Spencer8e665952004-08-29 05:24:01 +0000215Path::exists() const {
216 return 0 == access(path.c_str(), F_OK );
217}
218
219bool
220Path::readable() const {
221 return 0 == access(path.c_str(), F_OK | R_OK );
222}
223
224bool
225Path::writable() const {
226 return 0 == access(path.c_str(), F_OK | W_OK );
227}
228
229bool
230Path::executable() const {
231 return 0 == access(path.c_str(), R_OK | X_OK );
232}
233
234std::string
235Path::getLast() const {
236 // Find the last slash
237 size_t pos = path.rfind('/');
238
239 // Handle the corner cases
240 if (pos == std::string::npos)
241 return path;
242
243 // If the last character is a slash
244 if (pos == path.length()-1) {
245 // Find the second to last slash
246 size_t pos2 = path.rfind('/', pos-1);
247 if (pos2 == std::string::npos)
248 return path.substr(0,pos);
249 else
250 return path.substr(pos2+1,pos-pos2-1);
251 }
252 // Return everything after the last slash
253 return path.substr(pos+1);
254}
255
Reid Spencerb608a812004-11-16 06:15:19 +0000256void
257Path::getStatusInfo(StatusInfo& info) const {
Reid Spencer9195f372004-11-09 20:26:31 +0000258 struct stat buf;
259 if (0 != stat(path.c_str(), &buf)) {
260 ThrowErrno(std::string("Can't get status: ")+path);
261 }
262 info.fileSize = buf.st_size;
Reid Spencereaf18152004-11-14 22:08:36 +0000263 info.modTime.fromEpochTime(buf.st_mtime);
Reid Spencer9195f372004-11-09 20:26:31 +0000264 info.mode = buf.st_mode;
265 info.user = buf.st_uid;
266 info.group = buf.st_gid;
Reid Spencereaf18152004-11-14 22:08:36 +0000267 info.isDir = S_ISDIR(buf.st_mode);
268 if (info.isDir && path[path.length()-1] != '/')
269 path += '/';
270}
271
272bool
Reid Spencerb608a812004-11-16 06:15:19 +0000273Path::getDirectoryContents(std::set<Path>& result) const {
Reid Spencereaf18152004-11-14 22:08:36 +0000274 if (!isDirectory())
275 return false;
276 DIR* direntries = ::opendir(path.c_str());
277 if (direntries == 0)
278 ThrowErrno(path + ": can't open directory");
279
280 result.clear();
281 struct dirent* de = ::readdir(direntries);
282 while (de != 0) {
283 if (de->d_name[0] != '.') {
284 Path aPath(path + (const char*)de->d_name);
285 struct stat buf;
286 if (0 != stat(aPath.path.c_str(), &buf))
287 ThrowErrno(aPath.path + ": can't get status");
288 if (S_ISDIR(buf.st_mode))
289 aPath.path += "/";
Reid Spencerb608a812004-11-16 06:15:19 +0000290 result.insert(aPath);
Reid Spencereaf18152004-11-14 22:08:36 +0000291 }
292 de = ::readdir(direntries);
293 }
294
295 closedir(direntries);
296 return true;
Reid Spencer9195f372004-11-09 20:26:31 +0000297}
298
Reid Spencer8e665952004-08-29 05:24:01 +0000299bool
Reid Spencer07adb282004-11-05 22:15:36 +0000300Path::setDirectory(const std::string& a_path) {
Reid Spencer8e665952004-08-29 05:24:01 +0000301 if (a_path.size() == 0)
302 return false;
303 Path save(*this);
304 path = a_path;
305 size_t last = a_path.size() -1;
306 if (last != 0 && a_path[last] != '/')
307 path += '/';
Reid Spencer07adb282004-11-05 22:15:36 +0000308 if (!isValid()) {
Reid Spencer8e665952004-08-29 05:24:01 +0000309 path = save.path;
310 return false;
311 }
312 return true;
313}
314
315bool
Reid Spencer07adb282004-11-05 22:15:36 +0000316Path::setFile(const std::string& a_path) {
Reid Spencer8e665952004-08-29 05:24:01 +0000317 if (a_path.size() == 0)
318 return false;
319 Path save(*this);
320 path = a_path;
321 size_t last = a_path.size() - 1;
322 while (last > 0 && a_path[last] == '/')
323 last--;
324 path.erase(last+1);
Reid Spencer07adb282004-11-05 22:15:36 +0000325 if (!isValid()) {
Reid Spencer8e665952004-08-29 05:24:01 +0000326 path = save.path;
327 return false;
328 }
329 return true;
330}
331
332bool
Reid Spencer07adb282004-11-05 22:15:36 +0000333Path::appendDirectory(const std::string& dir) {
334 if (isFile())
Reid Spencer8e665952004-08-29 05:24:01 +0000335 return false;
336 Path save(*this);
337 path += dir;
338 path += "/";
Reid Spencer07adb282004-11-05 22:15:36 +0000339 if (!isValid()) {
Reid Spencer8e665952004-08-29 05:24:01 +0000340 path = save.path;
341 return false;
342 }
343 return true;
344}
345
346bool
Reid Spencer07adb282004-11-05 22:15:36 +0000347Path::elideDirectory() {
348 if (isFile())
Reid Spencer8e665952004-08-29 05:24:01 +0000349 return false;
350 size_t slashpos = path.rfind('/',path.size());
351 if (slashpos == 0 || slashpos == std::string::npos)
352 return false;
353 if (slashpos == path.size() - 1)
354 slashpos = path.rfind('/',slashpos-1);
355 if (slashpos == std::string::npos)
356 return false;
357 path.erase(slashpos);
358 return true;
359}
360
361bool
Reid Spencer07adb282004-11-05 22:15:36 +0000362Path::appendFile(const std::string& file) {
363 if (!isDirectory())
Reid Spencer8e665952004-08-29 05:24:01 +0000364 return false;
365 Path save(*this);
366 path += file;
Reid Spencer07adb282004-11-05 22:15:36 +0000367 if (!isValid()) {
Reid Spencer8e665952004-08-29 05:24:01 +0000368 path = save.path;
369 return false;
370 }
371 return true;
372}
373
374bool
Reid Spencer07adb282004-11-05 22:15:36 +0000375Path::elideFile() {
376 if (isDirectory())
Reid Spencer8e665952004-08-29 05:24:01 +0000377 return false;
378 size_t slashpos = path.rfind('/',path.size());
379 if (slashpos == std::string::npos)
380 return false;
381 path.erase(slashpos+1);
382 return true;
383}
384
385bool
Reid Spencer07adb282004-11-05 22:15:36 +0000386Path::appendSuffix(const std::string& suffix) {
387 if (isDirectory())
Reid Spencer8e665952004-08-29 05:24:01 +0000388 return false;
389 Path save(*this);
390 path.append(".");
391 path.append(suffix);
Reid Spencer07adb282004-11-05 22:15:36 +0000392 if (!isValid()) {
Reid Spencer8e665952004-08-29 05:24:01 +0000393 path = save.path;
394 return false;
395 }
396 return true;
397}
398
399bool
Reid Spencer07adb282004-11-05 22:15:36 +0000400Path::elideSuffix() {
401 if (isDirectory()) return false;
Reid Spencer8e665952004-08-29 05:24:01 +0000402 size_t dotpos = path.rfind('.',path.size());
403 size_t slashpos = path.rfind('/',path.size());
404 if (slashpos != std::string::npos && dotpos != std::string::npos &&
405 dotpos > slashpos) {
406 path.erase(dotpos, path.size()-dotpos);
407 return true;
408 }
409 return false;
410}
411
412
413bool
Reid Spencer07adb282004-11-05 22:15:36 +0000414Path::createDirectory( bool create_parents) {
Reid Spencer8e665952004-08-29 05:24:01 +0000415 // Make sure we're dealing with a directory
Reid Spencer07adb282004-11-05 22:15:36 +0000416 if (!isDirectory()) return false;
Reid Spencer8e665952004-08-29 05:24:01 +0000417
418 // Get a writeable copy of the path name
419 char pathname[MAXPATHLEN];
420 path.copy(pathname,MAXPATHLEN);
421
422 // Null-terminate the last component
423 int lastchar = path.length() - 1 ;
424 if (pathname[lastchar] == '/')
425 pathname[lastchar] = 0;
Reid Spencereaf18152004-11-14 22:08:36 +0000426 else
427 pathname[lastchar+1] = 0;
Reid Spencer8e665952004-08-29 05:24:01 +0000428
429 // If we're supposed to create intermediate directories
430 if ( create_parents ) {
431 // Find the end of the initial name component
432 char * next = strchr(pathname,'/');
433 if ( pathname[0] == '/')
434 next = strchr(&pathname[1],'/');
435
436 // Loop through the directory components until we're done
437 while ( next != 0 ) {
438 *next = 0;
439 if (0 != access(pathname, F_OK | R_OK | W_OK))
440 if (0 != mkdir(pathname, S_IRWXU | S_IRWXG))
441 ThrowErrno(std::string(pathname) + ": Can't create directory");
442 char* save = next;
Reid Spencereaf18152004-11-14 22:08:36 +0000443 next = strchr(next+1,'/');
Reid Spencer8e665952004-08-29 05:24:01 +0000444 *save = '/';
445 }
Reid Spencer8e665952004-08-29 05:24:01 +0000446 }
Reid Spencereaf18152004-11-14 22:08:36 +0000447
448 if (0 != access(pathname, F_OK | R_OK))
449 if (0 != mkdir(pathname, S_IRWXU | S_IRWXG))
450 ThrowErrno(std::string(pathname) + ": Can't create directory");
Reid Spencer8e665952004-08-29 05:24:01 +0000451 return true;
452}
453
454bool
Reid Spencer07adb282004-11-05 22:15:36 +0000455Path::createFile() {
Reid Spencer8e665952004-08-29 05:24:01 +0000456 // Make sure we're dealing with a file
Reid Spencer07adb282004-11-05 22:15:36 +0000457 if (!isFile()) return false;
Reid Spencer8e665952004-08-29 05:24:01 +0000458
459 // Create the file
Reid Spencer622e2202004-09-18 19:25:11 +0000460 int fd = ::creat(path.c_str(), S_IRUSR | S_IWUSR);
461 if (fd < 0)
Reid Spencer9195f372004-11-09 20:26:31 +0000462 ThrowErrno(path + ": Can't create file");
Reid Spencer622e2202004-09-18 19:25:11 +0000463 ::close(fd);
Reid Spencer8e665952004-08-29 05:24:01 +0000464
465 return true;
Reid Spencerb89a2232004-08-25 06:20:07 +0000466}
467
Reid Spencer8e665952004-08-29 05:24:01 +0000468bool
Reid Spencer9195f372004-11-09 20:26:31 +0000469Path::createTemporaryFile() {
470 // Make sure we're dealing with a file
471 if (!isFile()) return false;
472
473 // Append the filename filler
474 char pathname[MAXPATHLEN];
475 path.copy(pathname,MAXPATHLEN);
Reid Spencereaf18152004-11-14 22:08:36 +0000476 pathname[path.length()] = 0;
Reid Spencer9195f372004-11-09 20:26:31 +0000477 strcat(pathname,"XXXXXX");
478 int fd = ::mkstemp(pathname);
479 if (fd < 0) {
480 ThrowErrno(path + ": Can't create temporary file");
481 }
482 path = pathname;
483 ::close(fd);
484 return true;
485}
486
487bool
Reid Spencer07adb282004-11-05 22:15:36 +0000488Path::destroyDirectory(bool remove_contents) {
Reid Spencer8e665952004-08-29 05:24:01 +0000489 // Make sure we're dealing with a directory
Reid Spencer07adb282004-11-05 22:15:36 +0000490 if (!isDirectory()) return false;
Reid Spencer8e665952004-08-29 05:24:01 +0000491
492 // If it doesn't exist, we're done.
493 if (!exists()) return true;
494
495 if (remove_contents) {
496 // Recursively descend the directory to remove its content
497 std::string cmd("/bin/rm -rf ");
498 cmd += path;
499 system(cmd.c_str());
500 } else {
501 // Otherwise, try to just remove the one directory
502 char pathname[MAXPATHLEN];
503 path.copy(pathname,MAXPATHLEN);
504 int lastchar = path.length() - 1 ;
505 if (pathname[lastchar] == '/')
506 pathname[lastchar] = 0;
Reid Spencereaf18152004-11-14 22:08:36 +0000507 else
508 pathname[lastchar+1] = 0;
Reid Spencer8e665952004-08-29 05:24:01 +0000509 if ( 0 != rmdir(pathname))
510 ThrowErrno(std::string(pathname) + ": Can't destroy directory");
511 }
512 return true;
513}
514
515bool
Reid Spencer07adb282004-11-05 22:15:36 +0000516Path::destroyFile() {
517 if (!isFile()) return false;
Reid Spencer8e665952004-08-29 05:24:01 +0000518 if (0 != unlink(path.c_str()))
Reid Spencereaf18152004-11-14 22:08:36 +0000519 ThrowErrno(path + ": Can't destroy file");
520 return true;
521}
522
523bool
524Path::renameFile(const Path& newName) {
525 if (!isFile()) return false;
526 if (0 != rename(path.c_str(), newName.c_str()))
Reid Spencer1fce0912004-12-11 00:14:15 +0000527 ThrowErrno(std::string("can't rename ") + path + " as " +
528 newName.toString());
Reid Spencereaf18152004-11-14 22:08:36 +0000529 return true;
530}
531
532bool
533Path::setStatusInfo(const StatusInfo& si) const {
534 if (!isFile()) return false;
535 struct utimbuf utb;
536 utb.actime = si.modTime.toPosixTime();
537 utb.modtime = utb.actime;
538 if (0 != ::utime(path.c_str(),&utb))
539 ThrowErrno(path + ": can't set file modification time");
540 if (0 != ::chmod(path.c_str(),si.mode))
541 ThrowErrno(path + ": can't set mode");
Reid Spencer8e665952004-08-29 05:24:01 +0000542 return true;
543}
544
Reid Spencerb89a2232004-08-25 06:20:07 +0000545}
546
547// vim: sw=2