Subversion Repositories HelenOS

Rev

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

Rev 3386 Rev 4153
Line 35... Line 35...
35
#include <stdlib.h>
35
#include <stdlib.h>
36
#include <unistd.h>
36
#include <unistd.h>
37
#include <fcntl.h>
37
#include <fcntl.h>
38
#include <dirent.h>
38
#include <dirent.h>
39
#include <sys/types.h>
39
#include <sys/types.h>
-
 
40
#include <string.h>
40
 
41
 
41
#include "config.h"
42
#include "config.h"
42
#include "errors.h"
43
#include "errors.h"
43
#include "util.h"
44
#include "util.h"
44
#include "entry.h"
45
#include "entry.h"
Line 46... Line 47...
46
#include "cmds.h"
47
#include "cmds.h"
47
 
48
 
48
static char *cmdname = "touch";
49
static char *cmdname = "touch";
49
 
50
 
50
/* Dispays help for touch in various levels */
51
/* Dispays help for touch in various levels */
51
void * help_cmd_touch(unsigned int level)
52
void help_cmd_touch(unsigned int level)
52
{
53
{
53
    if (level == HELP_SHORT) {
54
    if (level == HELP_SHORT) {
54
        printf("`%s' updates access times for files\n", cmdname);
55
        printf("`%s' updates access times for files\n", cmdname);
55
    } else {
56
    } else {
56
        help_cmd_touch(HELP_SHORT);
57
        help_cmd_touch(HELP_SHORT);
57
        printf("  `%s' <file>, if the file does not exist it will be "
58
        printf("  `%s' <file>, if the file does not exist it will be "
58
                "created\n", cmdname);
59
                "created\n", cmdname);
59
    }
60
    }
60
 
61
 
61
    return CMD_VOID;
62
    return;
62
}
63
}
63
 
64
 
64
/* Main entry point for touch, accepts an array of arguments */
65
/* Main entry point for touch, accepts an array of arguments */
65
int * cmd_touch(char **argv)
66
int cmd_touch(char **argv)
66
{
67
{
67
    unsigned int argc, i = 0, ret = 0;
68
    unsigned int argc, i = 0, ret = 0;
68
    int fd;
69
    int fd;
69
    char *buff = NULL;
70
    char *buff = NULL;
70
 
71
 
Line 77... Line 78...
77
            cmdname, cmdname);
78
            cmdname, cmdname);
78
        return CMD_FAILURE;
79
        return CMD_FAILURE;
79
    }
80
    }
80
 
81
 
81
    for (i = 1; i < argc; i ++) {
82
    for (i = 1; i < argc; i ++) {
82
        buff = cli_strdup(argv[i]);
83
        buff = strdup(argv[i]);
83
        dirp = opendir(buff);
84
        dirp = opendir(buff);
84
        if (dirp) {
85
        if (dirp) {
85
            cli_error(CL_ENOTSUP, "%s is a directory", buff);
86
            cli_error(CL_ENOTSUP, "%s is a directory", buff);
86
            closedir(dirp);
87
            closedir(dirp);
87
            ret ++;
88
            ret ++;