Skip to content

Commit

Permalink
Ticket4407 case preserving filesystems
Browse files Browse the repository at this point in the history
fixes problem with re-generating files on case-preserving filesystems
  • Loading branch information
hkiel authored and OpenModelica-Hudson committed Jun 16, 2017
1 parent 73555c0 commit 709531b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Compiler/Util/omc_file.h
Expand Up @@ -100,7 +100,16 @@ static inline void om_file_open(__OMC_FILE *file, const char *filename, int mode
#endif
fclose(file->file);
}
#if defined(__APPLE_CC__)||defined(__MINGW32__)||defined(__MINGW64__)
if (mode == 1) {
file->file = fopen(filename, "rb");
} else {
unlink(filename);
file->file = fopen(filename, "wb");
}
#else
file->file = fopen(filename, mode == 1 ? "rb" : "wb");
#endif
file->name = filename;
#if defined(__OMC_FILE_DEBUG)
fprintf(stderr,"File.open: f:%s,%p,%p\n",file->name,file->file,file); fflush(NULL);
Expand Down
6 changes: 6 additions & 0 deletions Compiler/runtime/printimpl.c
Expand Up @@ -332,6 +332,9 @@ static int PrintImpl__writeBuf(threadData_t *threadData,const char* filename)
/* check if we have something to write */
/* open the file */
/* adrpo: 2010-09-22 open the file in BINARY mode as otherwise \r\n becomes \r\r\n! */
#if defined(__APPLE_CC__)||defined(__MINGW32__)||defined(__MINGW64__)
unlink(filename);
#endif
file = fopen(filename,fileOpenMode);
if (file == NULL) {
const char *c_tokens[1]={filename};
Expand Down Expand Up @@ -420,6 +423,9 @@ static int PrintImpl__writeBufConvertLines(threadData_t *threadData,const char *
/* check if we have something to write */
/* open the file */
/* adrpo: 2010-09-22 open the file in BINARY mode as otherwise \r\n becomes \r\r\n! */
#if defined(__APPLE_CC__)||defined(__MINGW32__)||defined(__MINGW64__)
unlink(filename);
#endif
file = fopen(filename,fileOpenMode);
if (file == NULL) {
const char *c_tokens[1]={filename};
Expand Down
6 changes: 6 additions & 0 deletions Compiler/runtime/systemimpl.c
Expand Up @@ -417,6 +417,9 @@ int SystemImpl__writeFile(const char* filename, const char* data)
#endif
FILE * file = NULL;
int len = strlen(data); /* MMC_HDRSTRLEN(MMC_GETHDR(rmlA1)); */
#if defined(__APPLE_CC__)||defined(__MINGW32__)||defined(__MINGW64__)
unlink(filename);
#endif
/* adrpo: 2010-09-22 open the file in BINARY mode as otherwise \r\n becomes \r\r\n! */
file = fopen(filename,fileOpenMode);
if (file == NULL) {
Expand Down Expand Up @@ -2939,6 +2942,9 @@ int SystemImpl__covertTextFileToCLiteral(const char *textFile, const char *outFi
goto done;
}
errno = 0;
#if defined(__APPLE_CC__)||defined(__MINGW32__)||defined(__MINGW64__)
unlink(outFile);
#endif
fout = fopen(outFile, "w");
if (!fout) {
const char *c_token[1]={strerror(errno)};
Expand Down

0 comments on commit 709531b

Please sign in to comment.