Skip to content

Commit

Permalink
fix #3 ascii diff on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mseminatore committed Apr 15, 2024
1 parent 2a6d81a commit 1c26b7a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion dsk.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifdef _WIN32
# define _CRT_SECURE_NO_WARNINGS
#endif

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
Expand Down Expand Up @@ -502,8 +506,10 @@ int dsk_add_file(DSK_Drive *drv, const char *filename, DSK_OPEN_MODE mode, DSK_F
}

// open the input file
#ifndef _WIN32
if (mode == DSK_MODE_ASCII)
pmode = "rt";
#endif

FILE *fin = fopen(filename, pmode);
if (!fin)
Expand Down Expand Up @@ -652,8 +658,11 @@ int dsk_extract_file(DSK_Drive *drv, const char *filename)
// open the output file
// open as text if ascii is set?
char* pmode = "wb";

#ifndef _WIN32
if (dirent->binary_ascii == DSK_ENCODING_ASCII)
pmode = "wt";
#endif

FILE *fout = fopen(filename, pmode);
if (!fout)
Expand Down Expand Up @@ -759,7 +768,7 @@ int dsk_del(DSK_Drive *drv, const char *filename)
//------------------------------------
// create a new DSK file
//------------------------------------
DSK_Drive *dsk_new(const char *filename)
DSK_Drive *dsk_new(char *filename)
{
char sector_data[DSK_BYTES_DATA_PER_SECTOR];

Expand Down
2 changes: 1 addition & 1 deletion dsk.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int dsk_free_bytes(DSK_Drive *drv);
int dsk_free_granules(DSK_Drive *drv);
int dsk_add_file(DSK_Drive *drv, const char *filename, DSK_OPEN_MODE mode, DSK_FILE_TYPE type);
int dsk_extract_file(DSK_Drive *drv, const char *filename);
DSK_Drive *dsk_new(const char *filename);
DSK_Drive *dsk_new(char *filename);
int dsk_format(DSK_Drive *drv);
int dsk_flush(DSK_Drive *drv);
int dsk_del(DSK_Drive *drv, const char *filename);
Expand Down

0 comments on commit 1c26b7a

Please sign in to comment.