From: <gnu...@li...> - 2001-06-06 01:48:49
|
GNUpdate CVS committal Author : chipx86 Module : libcomprex Path : /libcomprex Modified Files: fileio.c Log Message: Bug fixes, optimizations. =================================================================== RCS file: /cvsroot/gnupdate/libcomprex/libcomprex/fileio.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -3 -r1.1.1.1 -r1.2 --- fileio.c 2001/06/03 09:47:31 1.1.1.1 +++ fileio.c 2001/06/06 01:48:48 1.2 @@ -1,7 +1,7 @@ /** * @file fileio.c File input/output API * - * $Id: fileio.c,v 1.1.1.1 2001/06/03 09:47:31 chipx86 Exp $ + * $Id: fileio.c,v 1.2 2001/06/06 01:48:48 chipx86 Exp $ * * @Copyright (C) 1999-2001 The GNUpdate Project. * @@ -70,13 +70,14 @@ cxOpen(const char *path, const char *mode, CxDepth depth) { CxFileBatch *batch; - CxModule *schemeModule; - CxModule *fileModule; + CxModule *schemeModule = NULL; + CxModule *fileModule = NULL; CxStatus status; char *scheme, *newPath; char *outFilename, *outPath; char *baseName; - char discardable = 1; + char *ext; + char discardable; /* TODO: Remvoe this when writing is supported. */ if (strcmp(mode, "r")) @@ -110,10 +111,12 @@ if (!strcmp(scheme, "file")) { outFilename = strdup(path); - discardable = 1; + discardable = 0; } else { + discardable = 1; + /* Find the scheme module we'll use to get the file with. */ for (schemeModule = cxGetFirstModule(CX_MODULE_SCHEME); schemeModule != NULL; @@ -194,16 +197,18 @@ * Find the file module we'll use to compress/decompress the file with. * First try to auto-guess by extension. */ - for (fileModule = cxGetFirstModule(CX_MODULE_FILE); - fileModule != NULL; - fileModule = fileModule->next) - { - char *ext = strrchr(baseName, '.'); + ext = strrchr(baseName, '.'); + ext++; - ext++; - - if (fileModule->ops.file->supportsExtension(ext)) - break; + if (ext != NULL) + { + for (fileModule = cxGetFirstModule(CX_MODULE_FILE); + fileModule != NULL; + fileModule = fileModule->next) + { + if (fileModule->ops.file->supportsExtension(ext)) + break; + } } if (fileModule == NULL) |