From: <lab...@us...> - 2015-05-03 10:47:17
|
Revision: 1516 http://sourceforge.net/p/opengtoolkit/svn/1516 Author: labviewer Date: 2015-05-03 10:47:14 +0000 (Sun, 03 May 2015) Log Message: ----------- Add a function to enumerate directory contents with extra flag info Modified Paths: -------------- trunk/lvzip/c_source/lvutil.c trunk/lvzip/c_source/lvutil.h trunk/lvzip/c_source/unzip.c Modified: trunk/lvzip/c_source/lvutil.c =================================================================== --- trunk/lvzip/c_source/lvutil.c 2015-05-02 19:48:51 UTC (rev 1515) +++ trunk/lvzip/c_source/lvutil.c 2015-05-03 10:47:14 UTC (rev 1516) @@ -338,7 +338,10 @@ } return fIOErr; /* fIOErr generally signifies some unknown file error */ } +#endif +#endif +#if usesPosixPath || usesWinPath static int32 MakePathDSString(Path path, LStrPtr *lstr, int32 reserve) { int32 pathLen = -1; @@ -357,13 +360,81 @@ return err; } #endif -#endif LibAPI(void) DLLVersion(uChar* version) { sprintf((char*)version, "lvzlib V 2.2, date: %s, time: %s",__DATE__,__TIME__); } +LibAPI(MgErr) LVPath_ListDirectory(Path folderPath, LStrArrHdl *nameArr, FileInfoArrHdl *typeArr) +{ + MgErr err; + FInfoRec foldInfo; + FMListDetails **typeList = NULL; + FDirEntHandle nameList = NULL; + + if (!FIsAPath(folderPath)) + return mgArgErr; + /* Check that we have actually a folder */ + err = FGetInfo(folderPath, &foldInfo); + if (err) + return err; + if (!foldInfo.folder) + return mgArgErr; + + nameList = (FDirEntHandle)AZNewHClr(4); + if (!nameList) + return mFullErr; + typeList = (FMListDetails **)AZNewHandle(0); + if (!typeList) + { + AZDisposeHandle((UHandle)nameList); + return mFullErr; + } + err = FListDir(folderPath, nameList, typeList); + if (!err) + { + int32 i = 0, n = CPStrLen(*nameList); + UPtr fName = CPStrBuf(*nameList); + err = NumericArrayResize(uPtr, 1, (UHandle*)nameArr, n); + if (!err) + { + LStrHandle *names = (**nameArr)->elm; + err = NumericArrayResize(uL, 1, (UHandle*)typeArr, n * 2); + if (!err) + { + for (i = 0; i < n; i++, names++) + { + err = NumericArrayResize(uB, 1, (UHandle*)names, PStrLen(fName)); + if (err) + break; + + MoveBlock(PStrBuf(fName), LStrBuf(**names), PStrLen(fName)); + LStrLen(**names) = PStrLen(fName); + fName += PStrSize(fName); + } + MoveBlock((ConstUPtr)*typeList, (UPtr)((**typeArr)->elm), n * sizeof(FMListDetails)); + (**typeArr)->numItems = i; + } + n = (**nameArr)->numItems; + (**nameArr)->numItems = i; + /* Clear out possibly superfluous handles */ + if (n > i) + { + for (; i < n; i++, names++) + { + if (*names) + DSDisposeHandle((UHandle)*names); + *names = NULL; + } + } + } + } + AZDisposeHandle((UHandle)nameList); + AZDisposeHandle((UHandle)typeList); + return err; +} + LibAPI(MgErr) LVPath_HasResourceFork(Path path, LVBoolean *hasResFork, uInt32 *sizeLow, uInt32 *sizeHigh) { MgErr err = mgNoErr; Modified: trunk/lvzip/c_source/lvutil.h =================================================================== --- trunk/lvzip/c_source/lvutil.h 2015-05-02 19:48:51 UTC (rev 1515) +++ trunk/lvzip/c_source/lvutil.h 2015-05-03 10:47:14 UTC (rev 1516) @@ -186,6 +186,12 @@ typedef int32 Bool32; +#if ProcessorType==kX64 +#define uPtr uQ +#else +#define uPtr uL +#endif + /*** The Support Manager ***/ #define HiNibble(x) (uInt8)(((x)>>4) & 0x0F) @@ -336,6 +342,10 @@ #define LStrLenH(h) ((h) ? (*(h))->cnt : 0) #define LStrBufH(h) ((h) ? (*(h))->str : NULL) +/*** Concatenated Pascal String Support Functions ***/ +#define CPStrLen LStrLen /* concatenated Pascal vs. LabVIEW strings */ +#define CPStrBuf LStrBuf /* concatenated Pascal vs. LabVIEW strings */ + typedef struct { int32 cnt; uChar str[256]; @@ -521,6 +531,7 @@ #define kNotARefNum ((LVRefNum)0L) /* canonical invalid magic cookie */ /* LabVIEW exported functions */ +Bool32 FIsAPath(Path path); MgErr FPathToText(Path path, LStrPtr lstr); MgErr FPathToPath(Path *p); MgErr FAppendName(Path path, PStr name); @@ -544,12 +555,20 @@ UPtr DSNewPClr(size_t size); MgErr DSDisposePtr(UPtr); +UHandle DSNewHandle(size_t size); UHandle DSNewHClr(size_t size); MgErr DSSetHandleSize(UHandle, size_t); int32 DSGetHandleSize(UHandle); MgErr DSDisposeHandle(UHandle); MgErr DSCopyHandle(void *ph, const void *hsrc); +UHandle AZNewHandle(size_t size); +UHandle AZNewHClr(size_t size); +MgErr AZSetHandleSize(UHandle, size_t); +int32 AZGetHandleSize(UHandle); +MgErr AZDisposeHandle(UHandle); +MgErr AZCopyHandle(void *ph, const void *hsrc); + void MoveBlock(ConstUPtr ps, UPtr pd, size_t size); MgErr NumericArrayResize(int32, int32, UHandle*, size_t); @@ -557,6 +576,18 @@ #define Min(a, b) ((a) < (b)) ? (a) : (b) #define Max(a, b) ((a) > (b)) ? (a) : (b) +typedef struct +{ + int32 numItems; + LStrHandle elm[1]; +} LStrArrRec, *LStrArrPtr, **LStrArrHdl; + +typedef struct +{ + int32 numItems; + FMListDetails elm[1]; +} FileInfoArrRec, *FileInfoArrPtr, **FileInfoArrHdl; + /* Our exported functions */ LibAPI(void) DLLVersion OF((uChar* Version)); @@ -564,6 +595,7 @@ LibAPI(MgErr) LVPath_HasResourceFork(Path path, LVBoolean *hasResFork, uInt32 *sizeLow, uInt32 *sizeHigh); LibAPI(MgErr) LVPath_EncodeMacbinary(Path srcFileName, Path dstFileName); LibAPI(MgErr) LVPath_DecodeMacbinary(Path srcFileName, Path dstFileName); +LibAPI(MgErr) LVPath_ListDirectory(Path dirname, LStrArrHdl *names, FileInfoArrHdl *fileInfo); LibAPI(MgErr) LVPath_UtilFileInfo(Path path, uInt8 write, Modified: trunk/lvzip/c_source/unzip.c =================================================================== --- trunk/lvzip/c_source/unzip.c 2015-05-02 19:48:51 UTC (rev 1515) +++ trunk/lvzip/c_source/unzip.c 2015-05-03 10:47:14 UTC (rev 1516) @@ -2040,7 +2040,6 @@ return err; } - /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. @@ -2119,5 +2118,5 @@ ZEXTERN int ZEXPORT unzSetOffset (unzFile file, uLong pos) { - return unzSetOffset64(file,pos); + return unzSetOffset64(file, pos); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |