From: <enl...@li...> - 2001-04-03 12:28:06
|
Enlightenment CVS committal Author : cpk Project : e17 Module : apps/efsd Dir : e17/apps/efsd/efsd Modified Files: Makefile.am efsd.h efsd_io.c efsd_main.c efsd_misc.c efsd_misc.h efsd_options.c efsd_options.h libefsd.c libefsd.h Log Message: Do not list files starting with . unless efsd_op_all() is passed to efsd_listdir() or efsd_start_monitor(). =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/Makefile.am,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- Makefile.am 2001/04/03 11:32:40 1.14 +++ Makefile.am 2001/04/03 12:28:03 1.15 @@ -5,7 +5,7 @@ # A list of all the files in the current directory which can be regenerated MAINTAINERCLEANFILES = Makefile.in Makefile -INCLUDES = #-DDEBUG #-DDEBUG_NEST +INCLUDES = -DDEBUG #-DDEBUG_NEST include_HEADERS = \ efsd.h \ =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- efsd.h 2001/04/03 00:21:11 1.12 +++ efsd.h 2001/04/03 12:28:04 1.13 @@ -93,11 +93,12 @@ typedef enum efsd_option_type { - EFSD_OP_FS_FORCE, - EFSD_OP_FS_RECURSIVE, - EFSD_OP_LS_GET_STAT, - EFSD_OP_LS_GET_FILETYPE, - EFSD_OP_LS_GET_META + EFSD_OP_FORCE, + EFSD_OP_RECURSIVE, + EFSD_OP_ALL, + EFSD_OP_GET_STAT, + EFSD_OP_GET_FILETYPE, + EFSD_OP_GET_META } EfsdOptionType; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_io.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -3 -r1.27 -r1.28 --- efsd_io.c 2001/04/03 00:21:11 1.27 +++ efsd_io.c 2001/04/03 12:28:04 1.28 @@ -794,15 +794,17 @@ switch (eo->type) { - case EFSD_OP_FS_FORCE: + case EFSD_OP_FORCE: break; - case EFSD_OP_FS_RECURSIVE: + case EFSD_OP_RECURSIVE: break; - case EFSD_OP_LS_GET_STAT: + case EFSD_OP_GET_STAT: break; - case EFSD_OP_LS_GET_FILETYPE: + case EFSD_OP_ALL: break; - case EFSD_OP_LS_GET_META: + case EFSD_OP_GET_FILETYPE: + break; + case EFSD_OP_GET_META: len[len_index] = strlen(eo->efsd_op_ls_getmeta.key) + 1; iov[++n].iov_base = &len[len_index]; @@ -998,15 +1000,17 @@ { switch (eo->type) { - case EFSD_OP_FS_FORCE: + case EFSD_OP_FORCE: + break; + case EFSD_OP_RECURSIVE: break; - case EFSD_OP_FS_RECURSIVE: + case EFSD_OP_ALL: break; - case EFSD_OP_LS_GET_STAT: + case EFSD_OP_GET_STAT: break; - case EFSD_OP_LS_GET_FILETYPE: + case EFSD_OP_GET_FILETYPE: break; - case EFSD_OP_LS_GET_META: + case EFSD_OP_GET_META: result = read_ls_getmeta_op(sockfd, eo); break; default: =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_main.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- efsd_main.c 2001/04/03 00:21:11 1.8 +++ efsd_main.c 2001/04/03 12:28:04 1.9 @@ -173,7 +173,7 @@ { switch (efr->options[i].type) { - case EFSD_OP_LS_GET_STAT: + case EFSD_OP_GET_STAT: D(("Trying stat option on file-exists event on '%s'...\n", filename)); ec.type = EFSD_CMD_STAT; if (efsd_file_stat(&ec, efr->client) < 0) @@ -185,7 +185,7 @@ D(("Succeeded.\n")); } break; - case EFSD_OP_LS_GET_FILETYPE: + case EFSD_OP_GET_FILETYPE: D(("Trying getfile option on file-exists event on '%s'...\n", filename)); ec.type = EFSD_CMD_GETFILETYPE; if (efsd_file_getfile(&ec, efr->client) < 0) @@ -197,7 +197,7 @@ D(("Succeeded.\n")); } break; - case EFSD_OP_LS_GET_META: + case EFSD_OP_GET_META: D(("Trying get-meta option on file-exists event ...\n")); break; default: @@ -215,6 +215,7 @@ FAMEvent famev; EfsdEvent ee; char s[MAXPATHLEN]; + int i; D_ENTER; @@ -245,9 +246,19 @@ for (cl = efsd_list_head(m->clients); cl; cl = efsd_list_next(cl)) { EfsdFamRequest *efr; + char list_all_files = FALSE; efr = (EfsdFamRequest*) efsd_list_data(cl); + for (i = 0; i < efr->num_options; i++) + { + if (efr->options[i].type == EFSD_OP_ALL) + { + list_all_files = TRUE; + break; + } + } + switch (efr->type) { case EFSD_FAM_MONITOR_NORMAL: @@ -256,32 +267,36 @@ { ee.efsd_filechange_event.id = efr->id; - if (efsd_io_write_event(clientfd[efr->client], &ee) < 0) + if (list_all_files || !efsd_misc_file_is_dotfile(famev.filename)) { - if (errno == EPIPE) + if (efsd_io_write_event(clientfd[efr->client], &ee) < 0) { - D(("Client %i died -- closing connection.\n", efr->client)); - efsd_main_close_connection(efr->client); + if (errno == EPIPE) + { + D(("Client %i died -- closing connection.\n", efr->client)); + efsd_main_close_connection(efr->client); + } + else + { + efsd_queue_add_event(clientfd[efr->client], &ee); + D(("write() error when writing FAM event.\n")); + } } - else + + if (famev.code == FAMExists) { - efsd_queue_add_event(clientfd[efr->client], &ee); - D(("write() error when writing FAM event.\n")); + if (famev.filename[0] != '/') + { + snprintf(s, MAXPATHLEN, "%s/%s", m->filename, famev.filename); + efsd_handle_listdir_options(s, efr); + } + else + { + efsd_handle_listdir_options(famev.filename, efr); + } } } - if (famev.code == FAMExists) - { - if (famev.filename[0] != '/') - { - snprintf(s, MAXPATHLEN, "%s/%s", m->filename, famev.filename); - efsd_handle_listdir_options(s, efr); - } - else - { - efsd_handle_listdir_options(famev.filename, efr); - } - } } break; case EFSD_FAM_MONITOR_INTERNAL: =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_misc.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- efsd_misc.c 2001/03/30 18:40:50 1.16 +++ efsd_misc.c 2001/04/03 12:28:04 1.17 @@ -60,12 +60,12 @@ D_ENTER; if (!filename) - D_RETURN_(0); + D_RETURN_(FALSE); if ((st = efsd_stat(filename)) == NULL) - D_RETURN_(0); + D_RETURN_(FALSE); - D_RETURN_(1); + D_RETURN_(TRUE); } @@ -77,10 +77,10 @@ D_ENTER; if (!filename) - D_RETURN_(0); + D_RETURN_(FALSE); if ((st = efsd_stat(filename)) == NULL) - D_RETURN_(0); + D_RETURN_(FALSE); D_RETURN_(S_ISDIR(st->st_mode)); } @@ -94,28 +94,28 @@ D_ENTER; if (!filename) - D_RETURN_(0); + D_RETURN_(FALSE); if ((st = efsd_stat(filename)) == NULL) - D_RETURN_(0); + D_RETURN_(FALSE); if (st->st_uid == getuid()) { if (st->st_mode & S_IWUSR) - D_RETURN_(1); + D_RETURN_(TRUE); } else if (st->st_gid == getgid()) { if (st->st_mode & S_IWGRP) - D_RETURN_(1); + D_RETURN_(TRUE); } else { if (st->st_mode & S_IWOTH) - D_RETURN_(1); + D_RETURN_(TRUE); } - D_RETURN_(0); + D_RETURN_(FALSE); } @@ -127,28 +127,51 @@ D_ENTER; if (!filename) - D_RETURN_(0); + D_RETURN_(FALSE); if ((st = efsd_stat(filename)) == NULL) - D_RETURN_(0); + D_RETURN_(FALSE); if (st->st_uid == getuid()) { if (st->st_mode & S_IXUSR) - D_RETURN_(1); + D_RETURN_(TRUE); } else if (st->st_gid == getgid()) { if (st->st_mode & S_IXGRP) - D_RETURN_(1); + D_RETURN_(TRUE); } else { if (st->st_mode & S_IXOTH) - D_RETURN_(1); + D_RETURN_(TRUE); } - D_RETURN_(0); + D_RETURN_(FALSE); +} + + +int +efsd_misc_file_is_dotfile(char *filename) +{ + char *slash = NULL; + + D_ENTER; + + slash = strrchr(filename, '/'); + + if (slash) + filename = slash + 1; + + if (*filename == '.') + { + D(("%s is a dotfile.\n", filename)); + D_RETURN_(TRUE); + } + + D(("%s is NOT a dotfile.\n", filename)); + D_RETURN_(FALSE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_misc.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- efsd_misc.h 2001/03/21 14:05:18 1.12 +++ efsd_misc.h 2001/04/03 12:28:04 1.13 @@ -29,6 +29,7 @@ int efsd_misc_file_is_dir(char *filename); int efsd_misc_file_writeable(char *filename); int efsd_misc_file_execable(char *filename); +int efsd_misc_file_is_dotfile(char *filename); int efsd_misc_mkdir(char *filename); void efsd_misc_remove_trailing_slashes(char *path); int efsd_misc_is_absolute_path(char *path); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_options.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- efsd_options.c 2001/04/03 00:21:11 1.5 +++ efsd_options.c 2001/04/03 12:28:04 1.6 @@ -37,7 +37,7 @@ D_ENTER; eo = NEW(EfsdOption); memset(eo, 0, sizeof(EfsdOption)); - eo->type = EFSD_OP_LS_GET_STAT; + eo->type = EFSD_OP_GET_STAT; D_RETURN_(eo); } @@ -50,7 +50,7 @@ D_ENTER; eo = NEW(EfsdOption); memset(eo, 0, sizeof(EfsdOption)); - eo->type = EFSD_OP_LS_GET_META; + eo->type = EFSD_OP_GET_META; eo->efsd_op_ls_getmeta.key = strdup(key); eo->efsd_op_ls_getmeta.datatype = type; D_RETURN_(eo); @@ -65,7 +65,7 @@ D_ENTER; eo = NEW(EfsdOption); memset(eo, 0, sizeof(EfsdOption)); - eo->type = EFSD_OP_LS_GET_FILETYPE; + eo->type = EFSD_OP_GET_FILETYPE; D_RETURN_(eo); } @@ -78,7 +78,7 @@ D_ENTER; eo = NEW(EfsdOption); memset(eo, 0, sizeof(EfsdOption)); - eo->type = EFSD_OP_FS_FORCE; + eo->type = EFSD_OP_FORCE; D_RETURN_(eo); } @@ -91,11 +91,24 @@ D_ENTER; eo = NEW(EfsdOption); memset(eo, 0, sizeof(EfsdOption)); - eo->type = EFSD_OP_FS_RECURSIVE; + eo->type = EFSD_OP_RECURSIVE; D_RETURN_(eo); } +EfsdOption * +efsd_option_new_all(void) +{ + EfsdOption *eo; + + D_ENTER; + eo = NEW(EfsdOption); + memset(eo, 0, sizeof(EfsdOption)); + eo->type = EFSD_OP_ALL; + D_RETURN_(eo); +} + + void efsd_option_cleanup(EfsdOption *eo) { @@ -103,15 +116,17 @@ switch (eo->type) { - case EFSD_OP_FS_FORCE: + case EFSD_OP_FORCE: + break; + case EFSD_OP_RECURSIVE: break; - case EFSD_OP_FS_RECURSIVE: + case EFSD_OP_ALL: break; - case EFSD_OP_LS_GET_STAT: + case EFSD_OP_GET_STAT: break; - case EFSD_OP_LS_GET_FILETYPE: + case EFSD_OP_GET_FILETYPE: break; - case EFSD_OP_LS_GET_META: + case EFSD_OP_GET_META: FREE(eo->efsd_op_ls_getmeta.key); break; default: =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_options.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- efsd_options.h 2001/03/30 18:40:50 1.3 +++ efsd_options.h 2001/04/03 12:28:04 1.4 @@ -33,6 +33,7 @@ EfsdOption *efsd_option_new_get_filetype(void); EfsdOption *efsd_option_new_force(void); EfsdOption *efsd_option_new_recursive(void); +EfsdOption *efsd_option_new_all(void); /* ... and this one cleans up. The struct is NOT freed. */ void efsd_option_cleanup(EfsdOption *eo); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/libefsd.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -3 -r1.26 -r1.27 --- libefsd.c 2001/04/03 00:21:11 1.26 +++ libefsd.c 2001/04/03 12:28:04 1.27 @@ -376,9 +376,10 @@ op = va_arg(ap, EfsdOption*); /* sanity check -- pass only options that make sense. */ - if ((op->type == EFSD_OP_LS_GET_STAT) || - (op->type == EFSD_OP_LS_GET_FILETYPE) || - (op->type == EFSD_OP_LS_GET_META)) + if ((op->type == EFSD_OP_GET_STAT) || + (op->type == EFSD_OP_GET_FILETYPE) || + (op->type == EFSD_OP_GET_META) || + (op->type == EFSD_OP_ALL)) { ops = realloc(ops, sizeof(EfsdOption) * ++j); ops[j-1] = *op; @@ -668,9 +669,10 @@ op = va_arg(ap, EfsdOption*); /* sanity check -- pass only options that make sense. */ - if ((op->type == EFSD_OP_LS_GET_STAT) || - (op->type == EFSD_OP_LS_GET_FILETYPE) || - (op->type == EFSD_OP_LS_GET_META)) + if ((op->type == EFSD_OP_GET_STAT) || + (op->type == EFSD_OP_GET_FILETYPE) || + (op->type == EFSD_OP_GET_META) || + (op->type == EFSD_OP_ALL)) { ops = realloc(ops, sizeof(EfsdOption) * ++j); ops[j-1] = *op; @@ -762,4 +764,12 @@ { D_ENTER; D_RETURN_(efsd_option_new_recursive()); +} + + +EfsdOption * +efsd_op_all(void) +{ + D_ENTER; + D_RETURN_(efsd_option_new_all()); } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/libefsd.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- libefsd.h 2001/03/30 18:40:50 1.15 +++ libefsd.h 2001/04/03 12:28:04 1.16 @@ -207,6 +207,9 @@ EfsdOption *efsd_op_force(void); EfsdOption *efsd_op_recursive(void); +/* Include files starting with . in listings, like ls -a */ +EfsdOption *efsd_op_all(void); + #ifdef __cplusplus } #endif |