Bool CFileNameTo(U8 *dst, U8 *src) { MemSet(dst, 0, CDIR_FILENAME_LEN); if (!FileNameCheck(src)) return FALSE; StrCopy(dst, src); return TRUE; } I64 Name2DirClus(CDrive *drive, U8 *dirname) { Bool cont = TRUE, unlock; I64 cur_dir_clus; CDirEntry de; U8 *buf = StrNew(dirname), *buf2 = StrNew(dirname); DriveCheck(drive); try { unlock = DriveLock(drive); cur_dir_clus = drive->root_clus; while (*buf && cont) { StrFirstRemove(buf, "/", buf2); if (*buf2) { switch (drive->fs_type) { case FSt_REDSEA: cont = RedSeaFileFind(drive, cur_dir_clus, buf2, &de, FUF_JUST_DIRS); break; case FSt_FAT32: cont = FAT32FileFind(drive, cur_dir_clus, buf2, &de, FUF_JUST_DIRS); break; case FSt_ISO9660: cont = ISOFileFind(drive, cur_dir_clus, buf2, &de, FUF_JUST_DIRS); break; default: throw('Drive'); } cur_dir_clus = de.clus; } } if (!cont) { PrintErr("File not found: \"%s\".\n", dirname); cur_dir_clus = 0; } if (unlock) DriveUnlock(drive); } catch if (unlock) DriveUnlock(drive); Free(buf); Free(buf2); return cur_dir_clus; } I64 Name2ParentDirClus(CDrive *drive, U8 *dirname) { Bool cont = TRUE, unlock; I64 cur_dir_clus, cur_dir_clus2; CDirEntry de; U8 *buf = StrNew(dirname), *buf2 = StrNew(dirname); DriveCheck(drive); try { unlock = DriveLock(drive); cur_dir_clus = cur_dir_clus2 = drive->root_clus; while (*buf && cont) { cur_dir_clus2 = cur_dir_clus; StrFirstRemove(buf, "/", buf2); if (*buf2) { switch (drive->fs_type) { case FSt_REDSEA: cont = RedSeaFileFind(drive, cur_dir_clus, buf2, &de, FUF_JUST_DIRS); break; case FSt_FAT32: cont = FAT32FileFind(drive, cur_dir_clus, buf2, &de, FUF_JUST_DIRS); break; case FSt_ISO9660: cont = ISOFileFind(drive, cur_dir_clus, buf2, &de, FUF_JUST_DIRS); break; default: throw('Drive'); } cur_dir_clus = de.clus; } } if (!cont) { PrintErr("File not found: \"%s\".\n", dirname); cur_dir_clus2=0; } if (unlock) DriveUnlock(drive); } catch if (unlock) DriveUnlock(drive); Free(buf); Free(buf2); return cur_dir_clus2; }