4 #include <msp/core/systemerror.h>
14 Path readlink(const Path &link)
17 int len = ::readlink(link.c_str(), buf, sizeof(buf));
19 throw system_error("readlink");
20 return string(buf, len);
23 Path realpath(const Path &path)
25 deque<string> queue(path.begin(), path.end());
26 if(!path.is_absolute())
29 queue.insert(queue.begin(), cwd.begin(), cwd.end());
36 Path next = real/queue.front();
42 throw runtime_error("too many symbolic links");
43 Path link = readlink(next);
44 queue.insert(queue.begin(), link.begin(), link.end());
53 void rename(const Path &from, const Path &to)
55 if(::rename(from.c_str(), to.c_str())==-1)
56 throw system_error("rename");
59 void unlink(const Path &path)
61 if(::unlink(path.c_str())==-1)
62 throw system_error("unlink");