Skip to content

Commit 664045f

Browse files
authored
Merge pull request #43 from dholm/file_io/zip
file_io: Zip file support
2 parents 9b91e50 + 868c60f commit 664045f

33 files changed

+13127
-136
lines changed

DiskImage.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@ void TDiskImage::readUDI(int hfile, bool ronly)
12801280
}
12811281

12821282
//-----------------------------------------------------------------------------
1283-
void TDiskImage::writeTRD(int hfile)
1283+
void TDiskImage::writeTRD(fileTYPE *hfile)
12841284
{
12851285
VGFIND_SECTOR vgfs;
12861286

@@ -1295,13 +1295,13 @@ void TDiskImage::writeTRD(int hfile)
12951295
{
12961296
if (FindSector(trk, side, sec + 1, &vgfs))
12971297
{
1298-
write(hfile, vgfs.SectorPointer, 256);
1298+
FileWriteAdv(hfile, vgfs.SectorPointer, 256);
12991299
if ((!vgfs.CRCOK) || (!vgfs.vgfa.CRCOK)) printf("Warning: sector %d on track %d, side %d with BAD CRC!\n", sec + 1, trk, side);
13001300
if (vgfs.SectorLength != 256) printf("Warning: sector %d on track %d, side %d is non 256 bytes!\n", sec + 1, trk, side);
13011301
}
13021302
else
13031303
{
1304-
write(hfile, nullbuf, 256);
1304+
FileWriteAdv(hfile, nullbuf, 256);
13051305
printf("DANGER! Sector %d on track %d, side %d not found!\n", sec + 1, trk, side);
13061306
}
13071307
}
@@ -3014,19 +3014,10 @@ int x2trd(const char *name, fileTYPE *f)
30143014
return 0;
30153015
}
30163016

3017-
img->writeTRD(f->fd);
3017+
img->writeTRD(f);
30183018
delete(img);
30193019

3020-
struct stat64 st;
3021-
int ret = fstat64(f->fd, &st);
3022-
if (ret < 0)
3023-
{
3024-
printf("x2trd(fstat) error: %d.\n", ret);
3025-
FileClose(f);
3026-
return 0;
3027-
}
3028-
3029-
f->size = st.st_size;
3020+
f->size = FileGetSize(f);
30303021
FileSeekLBA(f, 0);
30313022
printf("x2trd: vtrd size=%llu.\n", f->size);
30323023

DiskImage.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class TDiskImage
8080

8181
void Open(const char *filename, bool ReadOnly);
8282

83-
void writeTRD(int hfile);
83+
void writeTRD(fileTYPE *hfile);
8484

8585
void readSCL(int hfile, bool readonly);
8686
void readFDI(int hfile, bool readonly);
@@ -189,4 +189,4 @@ int x2trd(const char *name, fileTYPE *f);
189189
int x2trd_ext_supp(const char *name);
190190

191191
//-----------------------------------------------------------------------------
192-
#endif
192+
#endif

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ endif
1717
INCLUDE = -I./
1818
INCLUDE += -I./support/minimig
1919
INCLUDE += -I./lib/libco
20+
INCLUDE += -I./lib/miniz
2021

2122
PRJ = MiSTer
2223
SRC = $(wildcard *.c)
@@ -28,11 +29,12 @@ ST_SRC = $(wildcard ./support/st/*.cpp)
2829
X86_SRC = $(wildcard ./support/x86/*.cpp)
2930
SNES_SRC = $(wildcard ./support/snes/*.cpp)
3031
LIBCO_SRC = lib/libco/arm.c
32+
MINIZ_SRC = $(wildcard ./lib/miniz/*.c)
3133

3234
VPATH = ./:./support/minimig:./support/sharpmz:./support/archie:./support/st:./support/x86:./support/snes
3335

34-
OBJ = $(SRC:.c=.c.o) $(SRC2:.cpp=.cpp.o) $(MINIMIG_SRC:.cpp=.cpp.o) $(SHARPMZ_SRC:.cpp=.cpp.o) $(ARCHIE_SRC:.cpp=.cpp.o) $(ST_SRC:.cpp=.cpp.o) $(X86_SRC:.cpp=.cpp.o) $(SNES_SRC:.cpp=.cpp.o) $(LIBCO_SRC:.c=.c.o)
35-
DEP = $(SRC:.c=.cpp.d) $(SRC2:.cpp=.cpp.d) $(MINIMIG_SRC:.cpp=.cpp.d) $(SHARPMZ_SRC:.cpp=.cpp.d) $(ARCHIE_SRC:.cpp=.cpp.d) $(ST_SRC:.cpp=.cpp.d) $(X86_SRC:.cpp=.cpp.d) $(SNES_SRC:.cpp=.cpp.d) $(LIBCO_SRC:.c=.c.d)
36+
OBJ = $(SRC:.c=.c.o) $(SRC2:.cpp=.cpp.o) $(MINIMIG_SRC:.cpp=.cpp.o) $(SHARPMZ_SRC:.cpp=.cpp.o) $(ARCHIE_SRC:.cpp=.cpp.o) $(ST_SRC:.cpp=.cpp.o) $(X86_SRC:.cpp=.cpp.o) $(SNES_SRC:.cpp=.cpp.o) $(LIBCO_SRC:.c=.c.o) $(MINIZ_SRC:.c=.c.o)
37+
DEP = $(SRC:.c=.cpp.d) $(SRC2:.cpp=.cpp.d) $(MINIMIG_SRC:.cpp=.cpp.d) $(SHARPMZ_SRC:.cpp=.cpp.d) $(ARCHIE_SRC:.cpp=.cpp.d) $(ST_SRC:.cpp=.cpp.d) $(X86_SRC:.cpp=.cpp.d) $(SNES_SRC:.cpp=.cpp.d) $(LIBCO_SRC:.c=.c.d) $(MINIZ_SRC:.c=.c.d)
3638

3739
DFLAGS = $(INCLUDE) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DVDATE=\"`date +"%y%m%d"`\"
3840
CFLAGS = $(DFLAGS) -Wall -Wextra -Wno-strict-aliasing -c -O3

0 commit comments

Comments
 (0)