return k;
}
+static bool filedir_exists(Unit *unit, a_inode *aino)
+{
+ struct mystat statbuf;
+ bool ok = true;
+ if (unit->volflags & MYVOLUMEINFO_ARCHIVE)
+ ok = zfile_stat_archive(aino->nname, &statbuf) != 0;
+ else if (unit->volflags & MYVOLUMEINFO_CDFS)
+ ok = isofs_stat(unit->ui.cdfs_superblock, aino->uniq_external, &statbuf);
+ else {
+ ok = my_existsfiledir(aino->nname);
+ }
+ return ok;
+}
+
#if TRACING_ENABLED
static void dumplock(TrapContext *ctx, Unit *unit, uaecptr lock)
{
if (err == 0 && (a->elock || (mode != SHARED_LOCK && a->shlock > 0))) {
err = ERROR_OBJECT_IN_USE;
}
+ if (err == 0) {
+ if (!filedir_exists(unit, a)) {
+ delete_aino(unit, a);
+ err = ERROR_OBJECT_NOT_AROUND;
+ }
+ }
/* Lock() doesn't do access checks. */
if (err != 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, err);
return;
}
+
if (mode == SHARED_LOCK)
a->shlock++;
else
extern bool my_createsoftlink(const TCHAR *path, const TCHAR *target);
extern bool my_createshortcut(const TCHAR *source, const TCHAR *target, const TCHAR *description);
extern void makesafefilename(TCHAR*, bool);
+extern bool my_existsfiledir(const TCHAR *name);
extern a_inode *custom_fsdb_lookup_aino_aname (a_inode *base, const TCHAR *aname);
extern a_inode *custom_fsdb_lookup_aino_nname (a_inode *base, const TCHAR *nname);
return attr;
}
+bool my_existsfiledir(const TCHAR *name)
+{
+ DWORD attr = GetFileAttributesSafe(name);
+ if (attr != INVALID_FILE_ATTRIBUTES)
+ return true;
+ DWORD err = GetLastError();
+ if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND) {
+ return false;
+ }
+ return true;
+}
+
int my_existsfile (const TCHAR *name)
{
DWORD attr;