xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 26f637448b5d9aed83098d0e2413352c3e2f2b89

Add results message for :touch command
Author: xaizek
Author date (UTC): 2011-11-13 19:00
Committer name: xaizek
Committer date (UTC): 2011-11-13 19:00
Parent(s): 940ff3c983f91bc51cc50a1b20def5d721358212
Signing key:
Tree: 45edbf386d7ad1ddd464c3a0d8fe08fe5c8ea0b5
File Lines added Lines deleted
src/commands.c 2 1
src/fileops.c 13 7
src/fileops.h 1 1
File src/commands.c changed (mode: 100644) (index 18b09ddb8..33ccc946d)
... ... sync_cmd(const cmd_info_t *cmd_info)
4339 4339 static int static int
4340 4340 touch_cmd(const cmd_info_t *cmd_info) touch_cmd(const cmd_info_t *cmd_info)
4341 4341 { {
4342 return make_files(curr_view, cmd_info->argv, cmd_info->argc) != 0;
4342 make_files(curr_view, cmd_info->argv, cmd_info->argc);
4343 return 1;
4343 4344 } }
4344 4345
4345 4346 static int static int
File src/fileops.c changed (mode: 100644) (index 1086d4251..376347dd7)
... ... make_dirs(FileView *view, char **names, int count, int create_parent)
3619 3619 status_bar_messagef("%d directorie%s created", n, (n == 1) ? "" : "s"); status_bar_messagef("%d directorie%s created", n, (n == 1) ? "" : "s");
3620 3620 } }
3621 3621
3622 int
3622 void
3623 3623 make_files(FileView *view, char **names, int count) make_files(FileView *view, char **names, int count)
3624 3624 { {
3625 3625 int i; int i;
3626 int n;
3626 3627 char buf[COMMAND_GROUP_INFO_LEN + 1]; char buf[COMMAND_GROUP_INFO_LEN + 1];
3627 3628 size_t len; size_t len;
3628 3629
 
... ... make_files(FileView *view, char **names, int count)
3632 3633 if(is_in_string_array(names, i, names[i])) if(is_in_string_array(names, i, names[i]))
3633 3634 { {
3634 3635 status_bar_errorf("Name \"%s\" duplicates", names[i]); status_bar_errorf("Name \"%s\" duplicates", names[i]);
3635 return 1;
3636 return;
3636 3637 } }
3637 3638 if(names[i][0] == '\0') if(names[i][0] == '\0')
3638 3639 { {
3639 3640 status_bar_errorf("Name #%d is empty", i + 1); status_bar_errorf("Name #%d is empty", i + 1);
3640 return 1;
3641 return;
3641 3642 } }
3642 3643 if(strchr(names[i], '/') != NULL) if(strchr(names[i], '/') != NULL)
3643 3644 { {
3644 3645 status_bar_errorf("Name \"%s\" contains slash", names[i]); status_bar_errorf("Name \"%s\" contains slash", names[i]);
3645 return 1;
3646 return;
3646 3647 } }
3647 3648 if(lstat(names[i], &st) == 0) if(lstat(names[i], &st) == 0)
3648 3649 { {
3649 3650 status_bar_errorf("File \"%s\" already exists", names[i]); status_bar_errorf("File \"%s\" already exists", names[i]);
3650 return 1;
3651 return;
3651 3652 } }
3652 3653 } }
3653 3654
 
... ... make_files(FileView *view, char **names, int count)
3656 3657
3657 3658 get_group_file_list(names, count, buf); get_group_file_list(names, count, buf);
3658 3659 cmd_group_begin(buf); cmd_group_begin(buf);
3660 n = 0;
3659 3661 for(i = 0; i < count; i++) for(i = 0; i < count; i++)
3660 3662 { {
3661 3663 char full[PATH_MAX]; char full[PATH_MAX];
3662 3664 snprintf(full, sizeof(full), "%s/%s", view->curr_dir, names[i]); snprintf(full, sizeof(full), "%s/%s", view->curr_dir, names[i]);
3663 3665 if(perform_operation(OP_MKFILE, NULL, full, NULL) == 0) if(perform_operation(OP_MKFILE, NULL, full, NULL) == 0)
3666 {
3664 3667 add_operation(OP_MKFILE, NULL, NULL, full, ""); add_operation(OP_MKFILE, NULL, NULL, full, "");
3668 n++;
3669 }
3665 3670 } }
3666 3671 cmd_group_end(); cmd_group_end();
3667 3672
3668 go_to_first_file(view, names, count);
3673 if(n > 0)
3674 go_to_first_file(view, names, count);
3669 3675
3670 return 0;
3676 status_bar_messagef("%d file%s created", n, (n == 1) ? "" : "s");
3671 3677 } }
3672 3678
3673 3679 /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
File src/fileops.h changed (mode: 100644) (index 5ae3e2fac..fe14326eb)
... ... int cpmv_files(FileView *view, char **list, int nlines, int move, int type,
68 68 int force); int force);
69 69 int cpmv_files_bg(FileView *view, char **list, int nlines, int move, int force); int cpmv_files_bg(FileView *view, char **list, int nlines, int move, int force);
70 70 void make_dirs(FileView *view, char **names, int count, int create_parent); void make_dirs(FileView *view, char **names, int count, int create_parent);
71 int make_files(FileView *view, char **names, int count);
71 void make_files(FileView *view, char **names, int count);
72 72
73 73 #ifdef TEST #ifdef TEST
74 74 const char * gen_clone_name(const char *normal_name); const char * gen_clone_name(const char *normal_name);
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master