741 sb->st_mtime = (fd->ftLastWriteTime.dwHighDateTime * MAXDWORD+1) + fd->ftLastWriteTime.dwLowDateTime; |
740 sb->st_mtime = (fd->ftLastWriteTime.dwHighDateTime * MAXDWORD+1) + fd->ftLastWriteTime.dwLowDateTime; |
742 sb->st_mode = (fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)? S_IFDIR : S_IFREG; |
741 sb->st_mode = (fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)? S_IFDIR : S_IFREG; |
743 return true; |
742 return true; |
744 } |
743 } |
745 |
744 |
746 // Browse to |
745 bool FiosGetDiskFreeSpace(const char *path, uint32 *tot) |
747 char *FiosBrowseTo(const FiosItem *item) |
|
748 { |
|
749 char *path = _fios_path; |
|
750 char *s; |
|
751 |
|
752 switch (item->type) { |
|
753 case FIOS_TYPE_DRIVE: |
|
754 sprintf(path, "%c:\\", item->title[0]); |
|
755 break; |
|
756 |
|
757 case FIOS_TYPE_PARENT: |
|
758 s = strrchr(path, '\\'); |
|
759 if (s != path + 2) { |
|
760 s[0] = '\0'; |
|
761 } else { |
|
762 s[1] = '\0'; |
|
763 } |
|
764 break; |
|
765 |
|
766 case FIOS_TYPE_DIR: |
|
767 if (path[3] != '\0') strcat(path, "\\"); |
|
768 strcat(path, item->name); |
|
769 break; |
|
770 |
|
771 case FIOS_TYPE_DIRECT: |
|
772 sprintf(path, "%s\\", item->name); |
|
773 s = strrchr(path, '\\'); |
|
774 if (s[1] == '\0') s[0] = '\0'; // strip trailing slash |
|
775 break; |
|
776 |
|
777 case FIOS_TYPE_FILE: |
|
778 case FIOS_TYPE_OLDFILE: |
|
779 case FIOS_TYPE_SCENARIO: |
|
780 case FIOS_TYPE_OLD_SCENARIO: { |
|
781 static char str_buffr[512]; |
|
782 |
|
783 sprintf(str_buffr, "%s\\%s", path, item->name); |
|
784 return str_buffr; |
|
785 } |
|
786 } |
|
787 |
|
788 return NULL; |
|
789 } |
|
790 |
|
791 /** |
|
792 * Get descriptive texts. Returns the path and free space |
|
793 * left on the device |
|
794 * @param path string describing the path |
|
795 * @param tfs total free space in megabytes, optional (can be NULL) |
|
796 * @return StringID describing the path (free space or failure) |
|
797 */ |
|
798 StringID FiosGetDescText(const char **path, uint32 *tot) |
|
799 { |
746 { |
800 UINT sem = SetErrorMode(SEM_FAILCRITICALERRORS); // disable 'no-disk' message box |
747 UINT sem = SetErrorMode(SEM_FAILCRITICALERRORS); // disable 'no-disk' message box |
|
748 bool retval = false; |
801 char root[4]; |
749 char root[4]; |
802 DWORD spc, bps, nfc, tnc; |
750 DWORD spc, bps, nfc, tnc; |
803 StringID sid; |
751 |
804 |
752 snprintf(root, lengthof(root), "%c:" PATHSEP, path[0]); |
805 *path = _fios_path; |
|
806 |
|
807 sprintf(root, "%c:\\", _fios_path[0]); |
|
808 if (tot != NULL && GetDiskFreeSpace(root, &spc, &bps, &nfc, &tnc)) { |
753 if (tot != NULL && GetDiskFreeSpace(root, &spc, &bps, &nfc, &tnc)) { |
809 *tot = ((spc * bps) * (uint64)nfc) >> 20; |
754 *tot = ((spc * bps) * (uint64)nfc) >> 20; |
810 sid = STR_4005_BYTES_FREE; |
755 retval = true; |
811 } else { |
|
812 sid = STR_4006_UNABLE_TO_READ_DRIVE; |
|
813 } |
756 } |
814 |
757 |
815 SetErrorMode(sem); // reset previous setting |
758 SetErrorMode(sem); // reset previous setting |
816 return sid; |
759 return retval; |
817 } |
760 } |
818 |
761 |
819 static int ParseCommandLine(char *line, char **argv, int max_argc) |
762 static int ParseCommandLine(char *line, char **argv, int max_argc) |
820 { |
763 { |
821 int n = 0; |
764 int n = 0; |