3 #include <msp/core/systemerror.h>
13 Path readlink(const Path &link)
16 int len = ::readlink(link.c_str(), buf, sizeof(buf));
18 throw system_error("readlink");
19 return string(buf, len);
22 Path realpath(const Path &path)
24 list<string> queue(path.begin(), path.end());
25 if(!path.is_absolute())
28 queue.insert(queue.begin(), cwd.begin(), cwd.end());
35 Path next = real/queue.front();
41 throw runtime_error("too many symbolic links");
42 Path link = readlink(next);
43 queue.insert(queue.begin(), link.begin(), link.end());
52 void rename(const Path &from, const Path &to)
54 if(::rename(from.c_str(), to.c_str())==-1)
55 throw system_error("rename");
58 void unlink(const Path &path)
60 if(::unlink(path.c_str())==-1)
61 throw system_error("unlink");