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 |