Subversion Repositories HelenOS

Rev

Rev 3265 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3265 Rev 3329
Line 28... Line 28...
28
 * POSSIBILITY OF SUCH DAMAGE.
28
 * POSSIBILITY OF SUCH DAMAGE.
29
 */
29
 */
30
 
30
 
31
#include <stdio.h>
31
#include <stdio.h>
32
#include <stdlib.h>
32
#include <stdlib.h>
-
 
33
 
-
 
34
#include "errors.h"
33
#include "entry.h"
35
#include "entry.h"
34
#include "cmds.h"
36
#include "cmds.h"
35
#include "pwd.h"
37
#include "pwd.h"
36
 
38
 
37
static char * cmdname = "pwd";
39
static char * cmdname = "pwd";
Line 42... Line 44...
42
    return CMD_VOID;
44
    return CMD_VOID;
43
}
45
}
44
   
46
   
45
int * cmd_pwd(char *argv[], cliuser_t *usr)
47
int * cmd_pwd(char *argv[], cliuser_t *usr)
46
{
48
{
-
 
49
    char *buff;
-
 
50
 
-
 
51
    buff = (char *) malloc(PATH_MAX);
47
    if (usr->cwd) {
52
    if (NULL == buff) {
48
        printf("%s\n", usr->cwd);
53
        cli_error(CL_ENOMEM, "%s:", cmdname);
49
        return CMD_SUCCESS;
54
        return CMD_FAILURE;
50
    } else
55
    }
51
        printf("/twilight/zone\n");
-
 
52
 
56
 
-
 
57
    memset(buff, 0, sizeof(buff));
-
 
58
    getcwd(buff, PATH_MAX);
-
 
59
 
-
 
60
    if (! buff) {
-
 
61
        cli_error(CL_EFAIL,
-
 
62
            "Unable to determine the current working directory");
-
 
63
        free(buff);
53
    return CMD_FAILURE;
64
        return CMD_FAILURE;
-
 
65
    } else {
-
 
66
        printf("%s\n", buff);
-
 
67
        free(buff);
-
 
68
        return CMD_SUCCESS;
-
 
69
    }
54
}
70
}