From fb719bceb294c7a9b88dbf43124d0165826e9272 Mon Sep 17 00:00:00 2001 From: scarab Date: Mon, 14 Jul 2008 20:35:45 +0000 Subject: - pridana autonomni kompilace na win (potreba pouze kompiler a cmake) git-svn-id: http://opensvn.csie.org/tuxanci_ng@140 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/base/textFile.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/base/textFile.c') diff --git a/src/base/textFile.c b/src/base/textFile.c index e5636ae..a996ac8 100755 --- a/src/base/textFile.c +++ b/src/base/textFile.c @@ -13,10 +13,12 @@ textFile_t* newTextFile(char *s) { textFile_t *new; char path[STR_PATH_SIZE]; - assert( s != NULL ); - +#ifndef __WIN32__ if( s[0] == '/' ) +#else + if( s[1] == ':' ) +#endif { strcpy(path, s); } @@ -26,7 +28,6 @@ textFile_t* newTextFile(char *s) strcat(path, "/"); strcat(path, s); } - new = malloc(sizeof(textFile_t)); new->file = strdup(path); new->text = newList(); @@ -86,7 +87,7 @@ textFile_t* loadTextFile(char *s) } file_length = buf.st_size; - if( (file = fopen(s, "rt")) == NULL ) + if( (file = fopen(s, "rb")) == NULL ) { fprintf(stderr, "ERROR: unable to open file %s for reading\n", s); return NULL; @@ -133,14 +134,16 @@ void saveTextFile(textFile_t *p) { int i; FILE *file; - assert( p != NULL ); - + file = fopen(p->file, "wt"); - for(i = 0; i < p->text->count; i++) { +#ifndef __WIN32__ fprintf(file, "%s\n", (char *)p->text->list[i]); +#else + fprintf(file, "%s\r\n", (char *)p->text->list[i]); +#endif } fclose(file); -- cgit v1.2.3