Skip to content
Browse files

CONFIG GET/SET dir implemented

  • Loading branch information...
1 parent 2446fbb commit ca9d961073ad74fffb197280f669140b579c745e @antirez committed Feb 14, 2011
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/config.c
View
14 src/config.c
@@ -426,6 +426,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);
@@ -448,6 +453,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);

0 comments on commit ca9d961

Please sign in to comment.
Something went wrong with that request. Please try again.