82 void ShowOSErrorBox(const char *buf) |
82 void ShowOSErrorBox(const char *buf) |
83 { |
83 { |
84 MyShowCursor(true); |
84 MyShowCursor(true); |
85 MessageBox(GetActiveWindow(), MB_TO_WIDE(buf), _T("Error!"), MB_ICONSTOP); |
85 MessageBox(GetActiveWindow(), MB_TO_WIDE(buf), _T("Error!"), MB_ICONSTOP); |
86 |
86 |
87 // if exception tracker is enabled, we crash here to let the exception handler handle it. |
87 /* if exception tracker is enabled, we crash here to let the exception handler handle it. */ |
88 #if defined(WIN32_EXCEPTION_TRACKER) && !defined(_DEBUG) |
88 #if defined(WIN32_EXCEPTION_TRACKER) && !defined(_DEBUG) |
89 if (*buf == '!') { |
89 if (*buf == '!') { |
90 _exception_string = buf; |
90 _exception_string = buf; |
91 *(byte*)0 = 0; |
91 *(byte*)0 = 0; |
92 } |
92 } |
745 } |
745 } |
746 } |
746 } |
747 |
747 |
748 bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb) |
748 bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb) |
749 { |
749 { |
750 // hectonanoseconds between Windows and POSIX epoch |
750 /* hectonanoseconds between Windows and POSIX epoch */ |
751 static const int64 posix_epoch_hns = 0x019DB1DED53E8000LL; |
751 static const int64 posix_epoch_hns = 0x019DB1DED53E8000LL; |
752 const WIN32_FIND_DATA *fd = &ent->dir->fd; |
752 const WIN32_FIND_DATA *fd = &ent->dir->fd; |
753 |
753 |
754 sb->st_size = ((uint64) fd->nFileSizeHigh << 32) + fd->nFileSizeLow; |
754 sb->st_size = ((uint64) fd->nFileSizeHigh << 32) + fd->nFileSizeLow; |
755 /* UTC FILETIME to seconds-since-1970 UTC |
755 /* UTC FILETIME to seconds-since-1970 UTC |
788 static int ParseCommandLine(char *line, char **argv, int max_argc) |
788 static int ParseCommandLine(char *line, char **argv, int max_argc) |
789 { |
789 { |
790 int n = 0; |
790 int n = 0; |
791 |
791 |
792 do { |
792 do { |
793 // skip whitespace |
793 /* skip whitespace */ |
794 while (*line == ' ' || *line == '\t') line++; |
794 while (*line == ' ' || *line == '\t') line++; |
795 |
795 |
796 // end? |
796 /* end? */ |
797 if (*line == '\0') break; |
797 if (*line == '\0') break; |
798 |
798 |
799 // special handling when quoted |
799 /* special handling when quoted */ |
800 if (*line == '"') { |
800 if (*line == '"') { |
801 argv[n++] = ++line; |
801 argv[n++] = ++line; |
802 while (*line != '"') { |
802 while (*line != '"') { |
803 if (*line == '\0') return n; |
803 if (*line == '\0') return n; |
804 line++; |
804 line++; |
829 hand = GetStdHandle(STD_OUTPUT_HANDLE); |
829 hand = GetStdHandle(STD_OUTPUT_HANDLE); |
830 GetConsoleScreenBufferInfo(hand, &coninfo); |
830 GetConsoleScreenBufferInfo(hand, &coninfo); |
831 coninfo.dwSize.Y = 500; |
831 coninfo.dwSize.Y = 500; |
832 SetConsoleScreenBufferSize(hand, coninfo.dwSize); |
832 SetConsoleScreenBufferSize(hand, coninfo.dwSize); |
833 |
833 |
834 // redirect unbuffered STDIN, STDOUT, STDERR to the console |
834 /* redirect unbuffered STDIN, STDOUT, STDERR to the console */ |
835 #if !defined(__CYGWIN__) |
835 #if !defined(__CYGWIN__) |
836 *stdout = *_fdopen( _open_osfhandle((intptr_t)hand, _O_TEXT), "w" ); |
836 *stdout = *_fdopen( _open_osfhandle((intptr_t)hand, _O_TEXT), "w" ); |
837 *stdin = *_fdopen(_open_osfhandle((intptr_t)GetStdHandle(STD_INPUT_HANDLE), _O_TEXT), "r" ); |
837 *stdin = *_fdopen(_open_osfhandle((intptr_t)GetStdHandle(STD_INPUT_HANDLE), _O_TEXT), "r" ); |
838 *stderr = *_fdopen(_open_osfhandle((intptr_t)GetStdHandle(STD_ERROR_HANDLE), _O_TEXT), "w" ); |
838 *stderr = *_fdopen(_open_osfhandle((intptr_t)GetStdHandle(STD_ERROR_HANDLE), _O_TEXT), "w" ); |
839 #else |
839 #else |
840 // open_osfhandle is not in cygwin |
840 /* open_osfhandle is not in cygwin */ |
841 *stdout = *fdopen(1, "w" ); |
841 *stdout = *fdopen(1, "w" ); |
842 *stdin = *fdopen(0, "r" ); |
842 *stdin = *fdopen(0, "r" ); |
843 *stderr = *fdopen(2, "w" ); |
843 *stderr = *fdopen(2, "w" ); |
844 #endif |
844 #endif |
845 |
845 |
944 #endif |
944 #endif |
945 |
945 |
946 void DetermineBasePaths(const char *exe) |
946 void DetermineBasePaths(const char *exe) |
947 { |
947 { |
948 _paths.personal_dir = _paths.game_data_dir = MallocT<char>(MAX_PATH); |
948 _paths.personal_dir = _paths.game_data_dir = MallocT<char>(MAX_PATH); |
|
949 _paths.second_data_dir = NULL; |
949 #if defined(UNICODE) |
950 #if defined(UNICODE) |
950 TCHAR path[MAX_PATH]; |
951 TCHAR path[MAX_PATH]; |
951 GetCurrentDirectory(MAX_PATH - 1, path); |
952 GetCurrentDirectory(MAX_PATH - 1, path); |
952 convert_from_fs(path, _paths.personal_dir, MAX_PATH); |
953 convert_from_fs(path, _paths.personal_dir, MAX_PATH); |
953 #else |
954 #else |
960 |
961 |
961 /** |
962 /** |
962 * Insert a chunk of text from the clipboard onto the textbuffer. Get TEXT clipboard |
963 * Insert a chunk of text from the clipboard onto the textbuffer. Get TEXT clipboard |
963 * and append this up to the maximum length (either absolute or screenlength). If maxlength |
964 * and append this up to the maximum length (either absolute or screenlength). If maxlength |
964 * is zero, we don't care about the screenlength but only about the physical length of the string |
965 * is zero, we don't care about the screenlength but only about the physical length of the string |
965 * @param tb @Textbuf type to be changed |
966 * @param tb Textbuf type to be changed |
966 * @return Return true on successfull change of Textbuf, or false otherwise |
967 * @return true on successfull change of Textbuf, or false otherwise |
967 */ |
968 */ |
968 bool InsertTextBufferClipboard(Textbuf *tb) |
969 bool InsertTextBufferClipboard(Textbuf *tb) |
969 { |
970 { |
970 HGLOBAL cbuf; |
971 HGLOBAL cbuf; |
971 char utf8_buf[512]; |
972 char utf8_buf[512]; |