diff --git a/src/exception.h b/src/exception.h index 0157915..47d9c78 100644 --- a/src/exception.h +++ b/src/exception.h @@ -47,7 +47,6 @@ struct Exception Type type; std::string msg; - Exception(Type type, const char *format, ...) : type(type) { diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 59459e9..d679a41 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -309,7 +309,7 @@ RGSS_openArchive(PHYSFS_Io *io, const char *, int forWrite) uint32_t magic = RGSS_MAGIC; /* Top level entry list */ - BoostSet &topLevel = data->dirHash["."]; + BoostSet &topLevel = data->dirHash[""]; while (true) { @@ -620,8 +620,7 @@ struct FileSystemPrivate const char *foundName = completeFileName(filename, type, foundExt); if (!foundName) - throw Exception(Exception::NoFileError, - "No such file or directory - %s", filename); + throw Exception(Exception::NoFileError, "%s", filename); PHYSFS_File *handle = PHYSFS_openRead(foundName); if (!handle) @@ -695,17 +694,23 @@ static void cacheEnumCB(void *d, const char *origdir, char buf[512]; - if (*origdir != '.') - snprintf(buf, sizeof(buf), "%s/%s", origdir, fname); - else + if (*origdir == '\0') strncpy(buf, fname, sizeof(buf)); + else + snprintf(buf, sizeof(buf), "%s/%s", origdir, fname); - std::string mixedCase(buf); + char *ptr = buf; + + /* Trim leading slash */ + if (*ptr == '/') + ++ptr; + + std::string mixedCase(ptr); for (char *p = buf; *p; ++p) *p = tolower(*p); - std::string lowerCase(buf); + std::string lowerCase(ptr); p->pathCache.insert(lowerCase, mixedCase); @@ -714,7 +719,7 @@ static void cacheEnumCB(void *d, const char *origdir, void FileSystem::createPathCache() { - PHYSFS_enumerateFilesCallback(".", cacheEnumCB, p); + PHYSFS_enumerateFilesCallback("", cacheEnumCB, p); p->havePathCache = true; } @@ -734,14 +739,15 @@ static Sint64 SDL_RWopsSize(SDL_RWops *ops) return PHYSFS_fileLength(f); } -static Sint64 SDL_RWopsSeek(SDL_RWops *ops, Sint64 offset, int whence) +static Sint64 SDL_RWopsSeek(SDL_RWops *ops, int64_t offset, int whence) { PHYSFS_File *f = sdlPHYS(ops); if (!f) return -1; - Sint64 base; + int64_t base; + switch (whence) { default: