diff options
author | tenox <as@tenoware.com> | 2017-01-15 03:23:33 -0800 |
---|---|---|
committer | tenox <as@tenoware.com> | 2017-01-15 03:23:33 -0800 |
commit | 34d5f06f39ef4051793b8200be0cc532ebf63c8f (patch) | |
tree | d63f8e8e6cc418c3336764e9aefa6aa767f9b3e2 | |
parent | c1a3a46007249c6de1c461b38a03ded6297df6de (diff) | |
download | wfm-34d5f06f39ef4051793b8200be0cc532ebf63c8f.tar.gz |
git subdirectory fix
-rw-r--r-- | dialogs.c | 3 | ||||
-rw-r--r-- | fileio.c | 36 | ||||
-rw-r--r-- | wfm.h | 6 |
3 files changed, 29 insertions, 16 deletions
@@ -260,6 +260,7 @@ void about(void) { "GCC: %s<BR>\n" "Server: %s<BR>\n" "User Agent: %s<BR>\n" + "NAME_MAX: %d<BR>\n" "JavaScript Level: %d<BR>\n" "Git Support: %s (%s)<BR>\n" " <P>\n" @@ -278,7 +279,7 @@ void about(void) { "<TR><TD COLSPAN=3 BGCOLOR=\"#EEEEEE\"> </TD></TR>\n" "</TABLE>\n" "</TD></TR></TABLE>\n</BODY></HTML>\n", - ICONSURL, TAGLINE, VERSION, __DATE__, __TIME__, __VERSION__, cgiServerSoftware, cgiUserAgent, js, + ICONSURL, TAGLINE, VERSION, __DATE__, __TIME__, __VERSION__, cgiServerSoftware, cgiUserAgent, NAME_MAX, js, #ifdef WFMGIT "Yes" #else @@ -82,7 +82,7 @@ void receivefile(void) { cgiFormFileClose(input); fclose(output); - revup_commit("Receive File"); + change_commit("Receive File"); redirect("%s?highlight=%s&directory=%s&token=%s", cgiScriptName, virt_filename_urlencoded, virt_dirname_urlencoded, token); @@ -104,7 +104,7 @@ void mkfile(void) { fclose(output); - revup_commit("New File"); + change_commit("New File"); redirect("%s?highlight=%s&directory=%s&token=%s", cgiScriptName, virt_filename_urlencoded, virt_dirname_urlencoded, token); @@ -205,7 +205,7 @@ void edit_save(void) { free(buff); - revup_commit("Editor Save"); + change_commit("Editor Save"); redirect("%s?highlight=%s&directory=%s&token=%s", cgiScriptName, virt_filename_urlencoded, virt_dirname_urlencoded, token); } @@ -267,7 +267,7 @@ void fileio_delete(void) { else { if(unlink(phys_filename)!=0) error("Unable to remove file.<BR>%s", strerror(errno)); - delete_commit("Delete File"); + delete_commit("Delete File"); } } @@ -304,15 +304,25 @@ void delete(void) { void fileio_move(void) { char final_destination[PHYS_DESTINATION_SIZE]={0}; struct stat fileinfo; + int move=0; + + // If moving file to a different directory we need to append the original file name to destination + if( stat(phys_destination, &fileinfo)==0 && S_ISDIR(fileinfo.st_mode) ) { + snprintf(final_destination, sizeof(final_destination), "%s/%s", phys_destination, virt_filename); + move=1; + } else { + strncpy(final_destination, phys_destination, sizeof(final_destination)); + move=0; + } + + if(rename(phys_filename, final_destination)!=0) + error("Unable to move file. <BR>[%d: %s]<BR>[SRC=%s] [DST=%s]", errno, strerror(errno), phys_filename, final_destination); + + if(move) + move_commit("Move File"); + else + rename_commit("Rename File"); - // If moving file to a different directory we need to append the original file name - if( stat(phys_destination, &fileinfo)==0 && S_ISDIR(fileinfo.st_mode) ) - snprintf(final_destination, sizeof(final_destination), "%s/%s", phys_destination, virt_filename); - else - strncpy(final_destination, phys_destination, sizeof(final_destination)); - - if(rename(phys_filename, final_destination)!=0) - error("Unable to move file. <BR>[%d: %s]<BR>[SRC=%s] [DST=%s]", errno, strerror(errno), phys_filename, final_destination); } // @@ -347,7 +357,7 @@ void move(void) { // Recursive Dir Size // // NOTE: will not count directories starting with . (dot) -// so size of git repo will not show here... +// so size of git repo will not be included off_t du(char *pdir) { DIR *dir; struct dirent *direntry; @@ -63,7 +63,7 @@ char VALIDCHRS_DIR[256]; // above + / #define SHM_SIZE 16 -#define VIRT_DIRNAME_SIZE NAME_MAX +#define VIRT_DIRNAME_SIZE NAME_MAX // around 255 #define PHYS_DIRNAME_SIZE 1024 #define VIRT_FILENAME_SIZE NAME_MAX #define PHYS_FILENAME_SIZE 1280 @@ -149,6 +149,8 @@ void html_title(char *); void singleprompt_ui(char *); char *url_encode(char *); char *url_decode(char *); -int revup_commit(char *); +int change_commit(char *); int delete_commit(char *); +int rename_commit(char *); +int move_commit(char *); int repo_check(void);
\ No newline at end of file |