From 0503d99d6459c47c28060071f5f1ccd0f10e0ceb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Wed, 10 Jul 2013 13:43:17 +0200 Subject: [PATCH] Catalog create(), setMode() and setOwner() implementation. --- src/VfsNs.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/VfsNs.cpp b/src/VfsNs.cpp index 8ac10c5..6b8163b 100644 --- a/src/VfsNs.cpp +++ b/src/VfsNs.cpp @@ -1,6 +1,7 @@ /// @file VfsNs.cpp /// @brief VFS namespace. /// @author Alejandro Álvarez Ayllón +#include #include #include #include @@ -182,7 +183,12 @@ void VfsCatalog::unlink(const std::string& path) throw (DmException) void VfsCatalog::create(const std::string& path, mode_t mode) throw (DmException) { - throw DmException(EACCES, "Write mode not supported"); + FILE *f; + + wrapCall(f = fopen(path.c_str(), "w")); + wrapCall(fclose(f)); + + setMode(path, mode); } @@ -196,14 +202,18 @@ mode_t VfsCatalog::umask(mode_t mask) throw () void VfsCatalog::setMode(const std::string& path, mode_t mode) throw (DmException) { - throw DmException(EACCES, "Write mode not supported"); + wrapCall(chmod(path.c_str(), mode)); } void VfsCatalog::setOwner(const std::string& path, uid_t newUid, gid_t newGid, bool followSymLink) throw (DmException) { - throw DmException(EACCES, "Write mode not supported"); + if (followSymLink) { + wrapCall(chown(path.c_str(), newUid, newGid)); + } else { + wrapCall(lchown(path.c_str(), newUid, newGid)); + } } -- 1.8.2.3