]> git.saurik.com Git - redis.git/blobdiff - src/config.c
CONFIG GET/SET dir implemented
[redis.git] / src / config.c
index 219c99ca0936a35c34bb5209aa3b43a9b58ec85b..673b771719d40dc33c84b995319086f1ff2ddab4 100644 (file)
@@ -423,6 +423,11 @@ void configSetCommand(redisClient *c) {
 
         if (yn == -1) goto badfmt;
         server.repl_serve_stale_data = yn;
+    } else if (!strcasecmp(c->argv[2]->ptr,"dir")) {
+        if (chdir((char*)o->ptr) == -1) {
+            addReplyErrorFormat(c,"Changing directory: %s", strerror(errno));
+            return;
+        }
     } else {
         addReplyErrorFormat(c,"Unsupported CONFIG parameter: %s",
             (char*)c->argv[2]->ptr);
@@ -445,6 +450,15 @@ void configGetCommand(redisClient *c) {
     int matches = 0;
     redisAssert(o->encoding == REDIS_ENCODING_RAW);
 
+    if (stringmatch(pattern,"dir",0)) {
+        char buf[1024];
+
+        buf[0] = '\0';
+        getcwd(buf,sizeof(buf));
+        addReplyBulkCString(c,"dir");
+        addReplyBulkCString(c,buf);
+        matches++;
+    }
     if (stringmatch(pattern,"dbfilename",0)) {
         addReplyBulkCString(c,"dbfilename");
         addReplyBulkCString(c,server.dbfilename);
@@ -555,6 +569,7 @@ void configCommand(redisClient *c) {
         server.stat_numcommands = 0;
         server.stat_numconnections = 0;
         server.stat_expiredkeys = 0;
+        resetCommandTableStats();
         addReply(c,shared.ok);
     } else {
         addReplyError(c,