summaryrefslogtreecommitdiff
path: root/orkbasecxx/Utils.cpp
diff options
context:
space:
mode:
authorGerald Begumisa <ben_g@users.sourceforge.net>2007-09-05 19:59:36 +0000
committerGerald Begumisa <ben_g@users.sourceforge.net>2007-09-05 19:59:36 +0000
commitf5408a17ac87c54a7a991e310147debf95123a5d (patch)
tree19136df6152b02ede0d9517e9fa27878f9994a63 /orkbasecxx/Utils.cpp
parent3aeac353ac9ecfdbbb29c80fa683628af070b019 (diff)
Added functionality to set the ownership of the directories leading up to the media file to the values specified in config.xml
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@481 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkbasecxx/Utils.cpp')
-rw-r--r--orkbasecxx/Utils.cpp58
1 files changed, 56 insertions, 2 deletions
diff --git a/orkbasecxx/Utils.cpp b/orkbasecxx/Utils.cpp
index fa670e4..3a6bc84 100644
--- a/orkbasecxx/Utils.cpp
+++ b/orkbasecxx/Utils.cpp
@@ -71,10 +71,16 @@ bool FileCanOpen(CStdString& path)
return false;
}
-void FileRecursiveMkdir(CStdString& path)
+void FileRecursiveMkdir(CStdString& path, int permissions, CStdString owner, CStdString group, CStdString rootDirectory)
{
- int position = 0;
+ int position = 0, newPermissions = permissions;
bool done = false;
+
+ /*
+ * Create the directories first. We have separated this because
+ * we do not want the introduction of rootDirectory to break
+ * any old functionality.
+ */
while (!done)
{
position = path.Find('/', position+1);
@@ -88,6 +94,54 @@ void FileRecursiveMkdir(CStdString& path)
ACE_OS::mkdir((PCSTR)level);
}
}
+
+ done = false;
+ position = 0;
+ if(rootDirectory.size())
+ {
+ if(path.Find(rootDirectory) >= 0)
+ {
+ position = 1 + rootDirectory.size();
+ }
+ }
+
+ if(newPermissions & S_IRUSR)
+ {
+ newPermissions |= S_IXUSR;
+ }
+
+ if(newPermissions & S_IRGRP)
+ {
+ newPermissions |= S_IXGRP;
+ }
+
+ if(newPermissions & S_IROTH)
+ {
+ newPermissions |= S_IXOTH;
+ }
+
+ while (!done)
+ {
+ position = path.Find('/', position+1);
+ if (position == -1)
+ {
+ done = true;
+ }
+ else
+ {
+ CStdString level = path.Left(position);
+
+ if(owner.size() && group.size())
+ {
+ FileSetOwnership(level, owner, group);
+ }
+
+ if(newPermissions)
+ {
+ FileSetPermissions(level, newPermissions);
+ }
+ }
+ }
}
int FileSetPermissions(CStdString filename, int permissions)