Fix conversions, add setMode() operation.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 16 Oct 2013 14:09:04 +0000 (16:09 +0200)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 16 Oct 2013 17:49:07 +0000 (19:49 +0200)
run.cpp

diff --git a/run.cpp b/run.cpp
index 1cf730a..7df59e0 100644 (file)
--- a/run.cpp
+++ b/run.cpp
@@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
        std::string arg;
 
        if (argc < 3) {
-               std::cout << "Usage: " << argv[0] << " [ DMLITE_CONFIGFILE [ s | d | h | (r|w|c) [PATH] | z [PATH [SIZE]] ] ]" << std::endl;
+               std::cout << "Usage: " << argv[0] << " [ DMLITE_CONFIGFILE [ s | d | h | (r|w|c) [PATH] | z [PATH [SIZE]] | m PATH mode ] ]" << std::endl;
                std::cout << "  s ... stat" << std::endl;
                std::cout << "  d ... opendir/readdir" << std::endl;
                std::cout << "  r ... read" << std::endl;
@@ -24,6 +24,7 @@ int main(int argc, char *argv[]) {
                std::cout << "  w ... whereToWrite" << std::endl;
                std::cout << "  c ... create" << std::endl;
                std::cout << "  z ... setSize" << std::endl;
+               std::cout << "  m ... setMode" << std::endl;
        }
 
        if (argc >= 2) conf = argv[1];
@@ -161,7 +162,7 @@ int main(int argc, char *argv[]) {
 
                        operation = "create";
 
-                       if (argc >= 5) mode = atoll(arg.c_str());
+                       if (argc >= 5) mode = strtoull(arg.c_str(), NULL, 8);
                        catalog->create(path, mode);
 
                        break;
@@ -172,11 +173,23 @@ int main(int argc, char *argv[]) {
 
                        operation = "set size";
                        size = 20000;
-                       if (argc >= 5) size = strtoull(arg.c_str(), NULL, 8);
+                       if (argc >= 5) size = strtoull(arg.c_str(), NULL, 10);
                        catalog->setSize(path, size);
 
                        break;
                }
+
+               case 'm': {
+                       mode_t mode;
+
+                       operation = "set mode";
+
+                       mode = 0644;
+                       if (argc >= 5) mode = strtoull(arg.c_str(), NULL, 8);
+                       catalog->setMode(path, mode);
+
+                       break;
+               }
                }
        } catch (dmlite::DmException& e) {
                std::cout << "Could not " << operation << "." << std::endl