static a_inode *custom_fsdb_lookup_aino (a_inode *base, const TCHAR *aname, int offset, int dontcreate) { uae_u8 fsdb[UAEFSDB2_LEN]; TCHAR *tmp1; HANDLE h; WIN32_FIND_DATA fd; static a_inode dummy; tmp1 = build_nname (base->nname, UAEFSDB_BEGINSX); if (!tmp1) return NULL; h = FindFirstFile (tmp1, &fd); if (h != INVALID_HANDLE_VALUE) { do { if (read_uaefsdb (base->nname, fd.cFileName, fsdb)) { TCHAR *s = au ((char*)fsdb + offset); if (same_aname (s, aname)) { int winmode; FindClose (h); xfree (tmp1); xfree (s); if (dontcreate) return &dummy; return aino_from_buf (base, fsdb, &winmode); } xfree (s); } } while (FindNextFile (h, &fd)); FindClose (h); } xfree (tmp1); return NULL; }
/* For an a_inode we have newly created based on a filename we found on the * native fs, fill in information about this file/directory. */ int fsdb_fill_file_attrs (a_inode *base, a_inode *aino) { int mode, winmode, oldamode; uae_u8 fsdb[UAEFSDB2_LEN]; int reset = 0; if((mode = GetFileAttributesSafe (aino->nname)) == INVALID_FILE_ATTRIBUTES) { write_log (_T("GetFileAttributes('%s') failed! error=%d, aino=%p dir=%d\n"), aino->nname, GetLastError(), aino, aino->dir); return 0; } aino->dir = (mode & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0; mode &= FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN; if ((base->volflags & MYVOLUMEINFO_STREAMS) && read_uaefsdb (aino->nname, NULL, fsdb)) { aino->amigaos_mode = do_get_mem_long ((uae_u32 *)(fsdb + 1)); xfree (aino->comment); aino->comment = NULL; if (fsdb[5 + 2 * 257]) aino->comment = my_strdup_ansi ((char*)fsdb + 5 + 2 * 257); xfree (aino_from_buf (base, fsdb, &winmode)); if (winmode == mode) /* no Windows-side editing? */ return 1; write_log (_T("FS: '%s' protection flags edited from Windows-side\n"), aino->nname); reset = 1; /* edited from Windows-side -> use Windows side flags instead */ } oldamode = aino->amigaos_mode; aino->amigaos_mode = A_FIBF_EXECUTE | A_FIBF_READ; if (!(FILE_ATTRIBUTE_ARCHIVE & mode)) aino->amigaos_mode |= A_FIBF_ARCHIVE; if (!(FILE_ATTRIBUTE_READONLY & mode)) aino->amigaos_mode |= A_FIBF_WRITE | A_FIBF_DELETE; if (FILE_ATTRIBUTE_SYSTEM & mode) aino->amigaos_mode |= A_FIBF_PURE; if (FILE_ATTRIBUTE_HIDDEN & mode) aino->amigaos_mode |= A_FIBF_HIDDEN; aino->amigaos_mode = filesys_parse_mask(aino->amigaos_mode); aino->amigaos_mode |= oldamode & A_FIBF_SCRIPT; if (reset && (base->volflags & MYVOLUMEINFO_STREAMS)) { create_uaefsdb (aino, fsdb, mode); write_uaefsdb (aino->nname, fsdb); } return 1; }
static a_inode *custom_fsdb_lookup_aino (a_inode *base, const TCHAR *aname, int offset, int dontcreate) { uae_u8 fsdb[UAEFSDB2_LEN]; TCHAR *tmp1; HANDLE h; WIN32_FIND_DATA fd; static a_inode dummy; const TCHAR *namep; TCHAR path[MAX_DPATH]; tmp1 = build_nname (base->nname, UAEFSDB_BEGINSX); if (!tmp1) return NULL; if (currprefs.win32_filesystem_mangle_reserved_names == false) { _tcscpy (path, PATHPREFIX); _tcscat (path, tmp1); namep = path; } else { namep = tmp1; } h = FindFirstFile (namep, &fd); if (h != INVALID_HANDLE_VALUE) { do { if (read_uaefsdb (base->nname, fd.cFileName, fsdb)) { TCHAR *s = au ((char*)fsdb + offset); if (same_aname (s, aname)) { int winmode; FindClose (h); xfree (tmp1); xfree (s); if (dontcreate) return &dummy; return aino_from_buf (base, fsdb, &winmode); } xfree (s); } } while (FindNextFile (h, &fd)); FindClose (h); } xfree (tmp1); return NULL; }