aboutsummaryrefslogtreecommitdiff
path: root/sword2
diff options
context:
space:
mode:
authorMax Horn2003-09-17 20:34:20 +0000
committerMax Horn2003-09-17 20:34:20 +0000
commitc0d1061a2dcfd8c50c70ca99b99a41e81207fa86 (patch)
tree6fda88871ad20b46c01da47f69fe6e5935c37d7b /sword2
parent0e5e39e64e640160192fe01a1e93964e3bdcb3b2 (diff)
downloadscummvm-rg350-c0d1061a2dcfd8c50c70ca99b99a41e81207fa86.tar.gz
scummvm-rg350-c0d1061a2dcfd8c50c70ca99b99a41e81207fa86.tar.bz2
scummvm-rg350-c0d1061a2dcfd8c50c70ca99b99a41e81207fa86.zip
cleanup
svn-id: r10277
Diffstat (limited to 'sword2')
-rw-r--r--sword2/driver/driver96.h1
-rw-r--r--sword2/driver/misc.cpp4
-rw-r--r--sword2/resman.cpp50
3 files changed, 18 insertions, 37 deletions
diff --git a/sword2/driver/driver96.h b/sword2/driver/driver96.h
index a669968f42..bf3ae4d1ad 100644
--- a/sword2/driver/driver96.h
+++ b/sword2/driver/driver96.h
@@ -1486,7 +1486,6 @@ extern int32 CloseMenuImmediately(void);
extern uint32 SVM_timeGetTime(void);
extern void SVM_SetFileAttributes(char *file, uint32 atrib);
extern void SVM_DeleteFile(char *file);
-extern void SVM_GetCurrentDirectory(uint32 max, char* path);
extern int32 SVM_GetVolumeInformation(char *cdPath, char *sCDName, uint32 maxPath, uint8 *, uint32 *dwMaxCompLength, uint32 *dwFSFlags, uint8 *, uint32 a);
extern void scumm_mkdir(const char *pathname);
extern void SVM_GetModuleFileName(void *module, char *destStr, uint32 maxLen);
diff --git a/sword2/driver/misc.cpp b/sword2/driver/misc.cpp
index 574b8877f8..cc427248e5 100644
--- a/sword2/driver/misc.cpp
+++ b/sword2/driver/misc.cpp
@@ -33,10 +33,6 @@ void SVM_DeleteFile(char *file) {
warning("stub DeleteFile");
}
-void SVM_GetCurrentDirectory(uint32 max, char* path) {
- warning("stub GetCurrentDirectory");
-}
-
int32 SVM_GetVolumeInformation(char *cdPath, char *sCDName, uint32 maxPath, uint8 *, uint32 *dwMaxCompLength, uint32 *dwFSFlags, uint8 *, uint32 a) {
warning("stub GetVolumeInformation %s", cdPath);
strcpy(sCDName, CD1_LABEL);
diff --git a/sword2/resman.cpp b/sword2/resman.cpp
index a886f6c5be..8c704a0ebe 100644
--- a/sword2/resman.cpp
+++ b/sword2/resman.cpp
@@ -75,10 +75,18 @@ resMan res_man; //declare the object global
#define LOCAL_CACHE 0x4 // Cluster is cached on HDD
#define LOCAL_PERM 0x8 // Cluster is on HDD.
+#if !defined(__GNUC__)
+ #pragma START_PACK_STRUCTS
+#endif
+
typedef struct {
uint8 clusterName[20]; // Null terminated cluster name.
uint8 cd; // Cd cluster is on and whether it is on the local drive or not.
-} _cd_inf;
+} GCC_PACK _cd_inf;
+
+#if !defined(__GNUC__)
+ #pragma END_PACK_STRUCTS
+#endif
// ---------------------------------------------------------------------------
@@ -1155,12 +1163,12 @@ void resMan::CacheNewCluster(uint32 newCluster) {
// Git rid of read-only status, if it is set.
SVM_SetFileAttributes(resource_files[newCluster], FILE_ATTRIBUTE_NORMAL);
- FILE *inFile, *outFile;
+ File inFile, outFile;
- inFile = fopen(buf, "rb");
- outFile = fopen(resource_files[newCluster], "wb");
+ inFile.open(buf, g_sword2->getGameDataPath());
+ outFile.open(resource_files[newCluster], g_sword2->getGameDataPath(), File::kFileWriteMode);
- if (inFile == NULL || outFile == NULL) {
+ if (!inFile.isOpen() || !outFile.isOpen()) {
Zdebug("Cache new cluster could not copy %s to %s", buf, resource_files[newCluster]);
Con_fatal_error("Cache new cluster could not copy %s to %s [file=%s line=%u]", buf, resource_files[newCluster], __FILE__, __LINE__);
}
@@ -1231,9 +1239,7 @@ void resMan::CacheNewCluster(uint32 newCluster) {
WaitForFade();
- fseek(inFile, 0, SEEK_END);
- uint32 size = ftell(inFile);
- fseek(inFile, 0, SEEK_SET);
+ uint32 size = inFile.size();
char buffer[BUFFERSIZE];
int stepSize = (size / BUFFERSIZE) / 100;
@@ -1243,9 +1249,9 @@ void resMan::CacheNewCluster(uint32 newCluster) {
uint32 realRead = 0;
do {
- realRead = fread(buffer, 1, BUFFERSIZE, inFile);
+ realRead = inFile.read(buffer, BUFFERSIZE);
read += realRead;
- if (fwrite(buffer, 1, realRead, outFile) != realRead) {
+ if (outFile.write(buffer, realRead) != realRead) {
Zdebug("Cache new cluster could not copy %s to %s", buf, resource_files[newCluster]);
Con_fatal_error("Cache new cluster could not copy %s to %s [file=%s line=%u]", buf, resource_files[newCluster], __FILE__, __LINE__);
}
@@ -1288,8 +1294,8 @@ void resMan::CacheNewCluster(uint32 newCluster) {
Con_fatal_error("Cache new cluster could not copy %s to %s [file=%s line=%u]", buf, resource_files[newCluster], __FILE__, __LINE__);
}
- fclose(inFile);
- fclose(outFile);
+ inFile.close();
+ outFile.close();
Free_mem(text_spr);
EraseBackBuffer(); // for hardware rendering
@@ -1328,26 +1334,6 @@ void resMan::CacheNewCluster(uint32 newCluster) {
fseek(file, -1, SEEK_CUR);
fwrite(&cdTab[newCluster], 1, 1, file);
fclose(file);
-
- // Now update DelList.log to indicate that this cluster should be
- // removed at uninstall.
- file = fopen("DelList.log", "r+");
-
- if (file != NULL) {
- fseek(file, -3, SEEK_END);
-
- char path[_MAX_PATH];
- SVM_GetCurrentDirectory(_MAX_PATH, path);
-
- strcat(path, "\\");
- strcat(path, resource_files[newCluster]);
- fwrite(path, 1, strlen(path), file);
-
- sprintf(path, "\nend");
- fwrite(path, 1, 4, file);
-
- fclose(file);
- }
}
void resMan::GetCd(int cd) {