#define _CRT_SECURE_NO_DEPRECATE #include "windows.h" #include <stdio.h> #include "fs.h" void sync_stat_callback(int inFileCount, long long inSyncSize) { #ifdef _DEBUG printf("Syncing %d files, with a total size of %d bytes.\n", inFileCount, inSyncSize); #endif } void file_stat_callback(const char* inDepotFile, const char* inClientFile, const char* inAction, int inRev, long long inFileSize) { const char* action = inAction; // Do some translation, so we produce the exact same output p4 would if (strcmp(action, "updated") == 0) action = "updating"; if (strcmp(action, "refreshed") == 0) action = "refreshing"; else if (strcmp(action, "added") == 0) action = "added as"; else if (strcmp(action, "deleted") == 0) action = "deleted as"; printf("%s#%d - %s %s\n", inDepotFile, inRev, action, inClientFile); } BOOL WINAPI ExceptionHandler(DWORD dwCtrlType) { AbortSync(); ExitProcess(FS_ABORTED); return TRUE; } int main(int argc, char **argv) { SetConsoleCtrlHandler(ExceptionHandler, TRUE); EResult result = Sync(argc, argv, "p4fs", sync_stat_callback, file_stat_callback); SetConsoleCtrlHandler(ExceptionHandler, FALSE); if (result == FS_HELP) { printf(GetErrorMessage()); } else if (result == FS_ERROR_NO_SYNC) { // Unsupported p4 command, redirect to p4 itself printf("Command unsupported by p4fs, redirecting to p4.\n"); STARTUPINFO start_up_info; ::memset(&start_up_info, 0, sizeof(STARTUPINFO)); start_up_info.cb = sizeof(STARTUPINFO); PROCESS_INFORMATION process_information; char command_line[2048] = "p4"; for (int i = 1; i < argc; ++i) { strcat(command_line, " "); strcat(command_line, argv[i]); } BOOL start_p4 = ::CreateProcess(NULL, command_line, NULL, NULL, TRUE, 0, NULL, NULL, &start_up_info, &process_information); if (start_p4) { ::WaitForSingleObject(process_information.hProcess, INFINITE); DWORD exit_code; ::GetExitCodeProcess(process_information.hProcess, &exit_code); ::CloseHandle(process_information.hProcess); ::CloseHandle(process_information.hThread); return exit_code; } else { char* message = NULL; DWORD last_err = ::GetLastError(); if (::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, last_err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR) &message, 0, NULL) > 0) { printf("Error starting p4 : %s\n", message); LocalFree(message); } else printf("Error starting p4, error code = %d.\n", last_err); result = FS_ERROR_P4; } } else if (result != FS_OK) { fprintf(stderr, GetErrorMessage()); fflush(stderr); } // So as not to interfere with normal p4 exit codes (which, as far as I can tell are undocumented) // We add 1000 to our exit code on failure. Success is still signaled by FS_OK (=0) if (result != FS_OK && result != FS_HELP) return result + 1000; return FS_OK; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 6451 | Frank Compagner |
- Now fully support unicode & utf-16 files - Improved accuracy of P4fsV progress bar - Added logging to help in remote debugging |
||
#2 | 6420 | Frank Compagner |
A number of improvements: - p4fs now supports the global -s (scripted output) option. - p4fs and P4fsV now support the modtime client option. - P4CHARSET is now correctly handled (though no full Unicode support yet). - Increased the maximum command line length for p4fs to the Windows maximum 32768. - Improved error handling. - Fixed a crash when cancelling a sync using the async or multithreaded writers. - P4fsV progressbar now behaves well when passing more than one filespec - P4fsV will now offer the option to overwrite any locally changed (but not checked out) files when it finds these during a sync (cannot clobber ...). - Made the P4fsV error dialog resizeable. - P4fsV Windows layout fixed so it works properly with all Windows style setings. - Ooh, and prettier icons too. |
||
#1 | 6187 | Frank Compagner | Added p4fs project |