From: <lab...@us...> - 2018-12-12 00:50:02
|
Revision: 1563 http://sourceforge.net/p/opengtoolkit/svn/1563 Author: labviewer Date: 2018-12-12 00:50:01 +0000 (Wed, 12 Dec 2018) Log Message: ----------- Some more platform specific corrections Modified Paths: -------------- trunk/lvzip/c_source/lvapi.c trunk/lvzip/c_source/lvapi.h trunk/lvzip/c_source/lvutil.c trunk/lvzip/c_source/lvutil.h trunk/lvzip/c_source/unzip.c trunk/lvzip/c_source/zlibvc.vcproj Modified: trunk/lvzip/c_source/lvapi.c =================================================================== --- trunk/lvzip/c_source/lvapi.c 2018-12-11 20:26:07 UTC (rev 1562) +++ trunk/lvzip/c_source/lvapi.c 2018-12-12 00:50:01 UTC (rev 1563) @@ -24,7 +24,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <string.h> -#include <mbstring.h> #define ZLIB_INTERNAL #include "zlib.h" #include "lvutil.h" @@ -78,12 +77,6 @@ static MagicCookieJar gCookieJar = NULL; -#if 0 -LibAPI(const char *) lvzlib_disposeRefnum(uptr_t *refnum) -{ - -} -#endif static int32 lvzlipCleanup(UPtr ptr) { FileNode *pNode = (FileNode*)ptr; @@ -448,13 +441,24 @@ * always work as intended for case insensitive comparison since only the normal * ASCII 7Bit alpha characters will be compared case insensitive, not any extended * characters or multibyte characters. + * 0 - platform specific + * 1 - case sensitive + * 2 - case insensitive * ****************************************************************************************************/ +#if Win32 +#define strcasecmp _stricmp +#endif static int caseInsensitiveNameComparer(unzFile file, const char *filename1, const char *filename2) { - return _mbsicmp((const unsigned char*)filename1, (const unsigned char*)filename2); + return strcasecmp(filename1, filename2); } +static int caseSensitiveNameComparer(unzFile file, const char *filename1, const char *filename2) +{ + return strcmp(filename1, filename2); +} + LibAPI(MgErr) lvzlib_unzLocateFile(LVRefNum *refnum, LStrHandle fileName, int iCaseSensitivity) { unzFile node; @@ -464,13 +468,26 @@ err = ZeroTerminateLString(&fileName); if (!err) { - err = LibToMgErr(unzLocateFile(node, (const char*)LStrBufH(fileName), iCaseSensitivity ? caseInsensitiveNameComparer : NULL)); + unzFileNameComparer filename_compare_func = NULL; + if ( +#if Mac || MSWin || VxWorks + !iCaseSensitivity || +#endif + iCaseSensitivity == 2) + { + filename_compare_func = caseInsensitiveNameComparer; + } + else + { + filename_compare_func = caseSensitiveNameComparer; + } + err = LibToMgErr(unzLocateFile(node, (const char*)LStrBufH(fileName), filename_compare_func)); } } return err; } -static MgErr RetrieveFileInfo(unzFile node, LStrHandle *fileName, uint16_t sizeFileName, LStrHandle *extraField, uint16_t sizeExtraField, LStrHandle *comment, uint16_t sizeComment) +static MgErr RetrieveFileInfo(unzFile node, unz_file_info *pfile_info, LStrHandle *fileName, uint16_t sizeFileName, LStrHandle *extraField, uint16_t sizeExtraField, LStrHandle *comment, uint16_t sizeComment) { MgErr err = NumericArrayResize(uB, 1, (UHandle*)extraField, sizeExtraField); if (!err) @@ -481,7 +498,7 @@ err = NumericArrayResize(uB, 1, (UHandle*)comment, sizeComment); if (!err) { - err = LibToMgErr(unzGetCurrentFileInfo64(node, NULL, (char*)LStrBuf(**fileName), sizeFileName, LStrBuf(**extraField), sizeExtraField, (char*)LStrBuf(**comment), sizeComment)); + err = LibToMgErr(unzGetCurrentFileInfo(node, pfile_info, (char*)LStrBuf(**fileName), sizeFileName, LStrBuf(**extraField), sizeExtraField, (char*)LStrBuf(**comment), sizeComment)); if (!err) { LStrLen(**extraField) = sizeExtraField; @@ -518,7 +535,7 @@ err = LibToMgErr(unzGetCurrentFileInfo(node, pfile_info, NULL, 0, NULL, 0, NULL, 0)); if (!err) { - err = RetrieveFileInfo(node, fileName, pfile_info->size_filename, extraField, pfile_info->size_file_extra, comment, pfile_info->size_file_comment); + err = RetrieveFileInfo(node, NULL, fileName, pfile_info->size_filename, extraField, pfile_info->size_file_extra, comment, pfile_info->size_file_comment); } } return err; @@ -534,7 +551,7 @@ err = LibToMgErr(unzGetCurrentFileInfo64(node, pfile_info, NULL, 0, NULL, 0, NULL, 0)); if (!err) { - err = RetrieveFileInfo(node, fileName, pfile_info->size_filename, extraField, pfile_info->size_file_extra, comment, pfile_info->size_file_comment); + err = RetrieveFileInfo(node, NULL, fileName, pfile_info->size_filename, extraField, pfile_info->size_file_extra, comment, pfile_info->size_file_comment); } } return err; @@ -659,6 +676,22 @@ return err; } +LibAPI(MgErr) lvzlib_unzGoToFirstFile2_32(LVRefNum *refnum, unz_file_info *pfile_info, LStrHandle *fileName, LStrHandle *extraField, LStrHandle *comment) +{ + unzFile node; + MgErr err = lvzlibGetRefnum(refnum, &node, UnzMagic); + if (!err) + { + unz_file_info64 file_info64; + err = LibToMgErr(unzGoToFirstFile2(node, &file_info64, NULL, 0, NULL, 0, NULL, 0)); + if (!err) + { + err = RetrieveFileInfo(node, pfile_info, fileName, file_info64.size_filename, extraField, file_info64.size_file_extra, comment, file_info64.size_file_comment); + } + } + return err; +} + LibAPI(MgErr) lvzlib_unzGoToFirstFile2_64(LVRefNum *refnum, unz_file_info64 *pfile_info, LStrHandle *fileName, LStrHandle *extraField, LStrHandle *comment) { unzFile node; @@ -668,7 +701,7 @@ err = LibToMgErr(unzGoToFirstFile2(node, pfile_info, NULL, 0, NULL, 0, NULL, 0)); if (!err) { - err = RetrieveFileInfo(node, fileName, pfile_info->size_filename, extraField, pfile_info->size_file_extra, comment, pfile_info->size_file_comment); + err = RetrieveFileInfo(node, NULL, fileName, pfile_info->size_filename, extraField, pfile_info->size_file_extra, comment, pfile_info->size_file_comment); } } return err; @@ -693,6 +726,22 @@ return err; } +LibAPI(MgErr) lvzlib_unzGoToNextFile2_32(LVRefNum *refnum, unz_file_info *pfile_info, LStrHandle *fileName, LStrHandle *extraField, LStrHandle *comment) +{ + unzFile node; + MgErr err = lvzlibGetRefnum(refnum, &node, UnzMagic); + if (!err) + { + unz_file_info64 file_info64; + err = LibToMgErr(unzGoToNextFile2(node, &file_info64, NULL, 0, NULL, 0, NULL, 0)); + if (!err) + { + err = RetrieveFileInfo(node, pfile_info, fileName, file_info64.size_filename, extraField, file_info64.size_file_extra, comment, file_info64.size_file_comment); + } + } + return err; +} + LibAPI(MgErr) lvzlib_unzGoToNextFile2_64(LVRefNum *refnum, unz_file_info64 *pfile_info, LStrHandle *fileName, LStrHandle *extraField, LStrHandle *comment) { unzFile node; @@ -702,7 +751,7 @@ err = LibToMgErr(unzGoToNextFile2(node, pfile_info, NULL, 0, NULL, 0, NULL, 0)); if (!err) { - err = RetrieveFileInfo(node, fileName, pfile_info->size_filename, extraField, pfile_info->size_file_extra, comment, pfile_info->size_file_comment); + err = RetrieveFileInfo(node, NULL, fileName, pfile_info->size_filename, extraField, pfile_info->size_file_extra, comment, pfile_info->size_file_comment); } } return err; Modified: trunk/lvzip/c_source/lvapi.h =================================================================== --- trunk/lvzip/c_source/lvapi.h 2018-12-11 20:26:07 UTC (rev 1562) +++ trunk/lvzip/c_source/lvapi.h 2018-12-12 00:50:01 UTC (rev 1563) @@ -55,8 +55,10 @@ LibAPI(MgErr) lvzlib_unzReadCurrentFile(LVRefNum *refnum, LStrHandle buffer); LibAPI(MgErr) lvzlib_unzCloseCurrentFile(LVRefNum *refnum); LibAPI(MgErr) lvzlib_unzGoToFirstFile(LVRefNum *refnum); +LibAPI(MgErr) lvzlib_unzGoToFirstFile2_32(LVRefNum *refnum, unz_file_info *pfile_info, LStrHandle *fileName, LStrHandle *extraField, LStrHandle *comment); LibAPI(MgErr) lvzlib_unzGoToFirstFile2_64(LVRefNum *refnum, unz_file_info64 *pfile_info, LStrHandle *fileName, LStrHandle *extraField, LStrHandle *comment); LibAPI(MgErr) lvzlib_unzGoToNextFile(LVRefNum *refnum); +LibAPI(MgErr) lvzlib_unzGoToNextFile2_32(LVRefNum *refnum, unz_file_info *pfile_info, LStrHandle *fileName, LStrHandle *extraField, LStrHandle *comment); LibAPI(MgErr) lvzlib_unzGoToNextFile2_64(LVRefNum *refnum, unz_file_info64 *pfile_info, LStrHandle *fileName, LStrHandle *extraField, LStrHandle *comment); LibAPI(MgErr) lvzlib_unzGoToFilePos32(LVRefNum *refnum, unz_file_pos *pos); LibAPI(MgErr) lvzlib_unzGoToFilePos64(LVRefNum *refnum, unz64_file_pos *pos); Modified: trunk/lvzip/c_source/lvutil.c =================================================================== --- trunk/lvzip/c_source/lvutil.c 2018-12-11 20:26:07 UTC (rev 1562) +++ trunk/lvzip/c_source/lvutil.c 2018-12-12 00:50:01 UTC (rev 1563) @@ -487,7 +487,7 @@ #if Unix || MacOSX || defined(EMBEDDED) #define LWStrPtr LStrPtr - +/* wstr is filled with an 8 bit local encoded string from the path, which could be UTF8 on Linux and MacOSX systems */ static int32 MakePathDSString(Path path, LWStrPtr *lstr, int32 reserve) { int32 pathLen = -1; @@ -507,7 +507,7 @@ } #elif usesWinPath #define LWStrPtr UStrPtr - +/* wstr is filled with a Windows UTF16LE string from the path */ static int32 MakePathDSString(Path path, LWStrPtr *wstr, int32 reserve) { int32 pathLen = -1; @@ -540,7 +540,7 @@ len = 6; off = 1; } - *wstr = (UStrPtr)DSNewPClr(sizeof(int32) + sizeof(wchar_t) * (len + pathLen + reserve + 1)); + *wstr = (LWStrPtr)DSNewPClr(sizeof(int32) + sizeof(wchar_t) * (len + pathLen + reserve + 1)); if (*wstr) { if (buf[0] && buf[1] == ':') @@ -1566,13 +1566,11 @@ { DIR *dirp; struct dirent *dp; - struct direntpath dppath; - struct dirent *dpp = (struct dirent *)&dppath; if (!(dirp = opendir((const char*)lstr->str))) return UnixToLVFileErr(); - for (dp = readdir_r(dirp, dpp); dp; dp = readdir_r(dirp, dpp)) + for (dp = readdir(dirp); dp; dp = readdir(dirp)) count++; closedir(dirp); fileInfo->size = count - 2; Modified: trunk/lvzip/c_source/lvutil.h =================================================================== --- trunk/lvzip/c_source/lvutil.h 2018-12-11 20:26:07 UTC (rev 1562) +++ trunk/lvzip/c_source/lvutil.h 2018-12-12 00:50:01 UTC (rev 1563) @@ -455,10 +455,10 @@ uInt32 cdate; /**< creation date */ uInt32 mdate; /**< last modification date */ Bool32 folder; /**< indicates whether path refers to a folder */ - Bool32 isInvisible; /**< indicates whether the file is visible in File Dialog */ + Bool32 isInvisible; /**< indicates whether the file is visible in File Dialog */ struct { int16 v, h; - } location; /**< system specific geographical location */ + } location; /**< system specific geographical location */ Str255 owner; /**< owner (in pascal string form) of file or folder */ Str255 group; /**< group (in pascal string form) of file or folder */ } FInfoRec, *FInfoPtr; Modified: trunk/lvzip/c_source/unzip.c =================================================================== --- trunk/lvzip/c_source/unzip.c 2018-12-11 20:26:07 UTC (rev 1562) +++ trunk/lvzip/c_source/unzip.c 2018-12-12 00:50:01 UTC (rev 1563) @@ -906,7 +906,7 @@ unz_file_info64 file_info64; int err = UNZ_OK; - err = unzGetCurrentFileInfoInternal(file, &file_info64, NULL, filename, filename_size, + err = unzGetCurrentFileInfoInternal(file, pfile_info ? &file_info64 : NULL, NULL, filename, filename_size, extrafield, extrafield_size, comment, comment_size); if ((err == UNZ_OK) && (pfile_info != NULL)) Modified: trunk/lvzip/c_source/zlibvc.vcproj =================================================================== --- trunk/lvzip/c_source/zlibvc.vcproj 2018-12-11 20:26:07 UTC (rev 1562) +++ trunk/lvzip/c_source/zlibvc.vcproj 2018-12-12 00:50:01 UTC (rev 1563) @@ -393,7 +393,7 @@ <Tool Name="VCCLCompilerTool" Optimization="2" - InlineFunctionExpansion="1" + InlineFunctionExpansion="0" AdditionalIncludeDirectories="bzip2" PreprocessorDefinitions="WIN32;NDEBUG;NO_vsnprintf;HAVE_AES;HAVE_BZIP2;BZ_NO_STDIO;_CRT_SECURE_NO_WARNINGS" StringPooling="true" @@ -491,7 +491,7 @@ <Tool Name="VCCLCompilerTool" Optimization="2" - InlineFunctionExpansion="1" + InlineFunctionExpansion="0" AdditionalIncludeDirectories="bzip2" PreprocessorDefinitions="WIN32;NDEBUG;NO_vsnprintf;HAVE_AES;HAVE_BZIP2;BZ_NO_STDIO;_CRT_SECURE_NO_WARNINGS" StringPooling="true" @@ -1933,34 +1933,6 @@ <File RelativePath=".\utf.c" > - <FileConfiguration - Name="DLL Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - <FileConfiguration - Name="DLL Release|x64" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - <FileConfiguration - Name="DLL Embedded|Win32" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - <FileConfiguration - Name="DLL Embedded|x64" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> </File> <File RelativePath="zip.c" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |