libcm is a C development framework with an emphasis on audio signal processing applications.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

cmFileSys.c 31KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354
  1. #include "cmPrefix.h"
  2. #include "cmGlobal.h"
  3. #include "cmRpt.h"
  4. #include "cmErr.h"
  5. #include "cmCtx.h"
  6. #include "cmMem.h"
  7. #include "cmMallocDebug.h"
  8. #include "cmLinkedHeap.h"
  9. #include "cmFileSys.h"
  10. #include <sys/stat.h>
  11. #include <errno.h>
  12. #include <libgen.h> // basename(), dirname()
  13. #include <dirent.h> // opendir()/readdir()
  14. #include <limits.h> // PATH_MAX
  15. #include <sys/types.h> // mkdir
  16. #ifdef OS_OSX
  17. #include "osx/cmFileSysOsx.h"
  18. #endif
  19. #ifdef OS_LINUX
  20. #include "linux/cmFileSysLinux.h"
  21. #endif
  22. cmFileSysH_t cmFileSysNullHandle = {NULL};
  23. typedef struct
  24. {
  25. cmErr_t err;
  26. cmLHeapH_t heapH;
  27. const cmChar_t* appNameStr;
  28. #ifdef OS_OSX
  29. _cmFsOsx_t* p;
  30. cmChar_t* prefDir;
  31. #endif
  32. #ifdef OS_LINUX
  33. _cmFsLinux_t* p;
  34. #endif
  35. } cmFs_t;
  36. cmFsRC_t _cmFileSysError( cmFs_t* p, cmFsRC_t rc, int sysErr, const cmChar_t* fmt, ... )
  37. {
  38. va_list vl;
  39. va_start(vl,fmt);
  40. if( sysErr == 0 )
  41. rc = cmErrVMsg(&p->err,rc,fmt,vl);
  42. else
  43. {
  44. const unsigned bufCharCnt = 511;
  45. cmChar_t buf[bufCharCnt+1];
  46. vsnprintf(buf,bufCharCnt,fmt,vl);
  47. rc = cmErrMsg(&p->err,rc,"%s\nSystem Msg:%s",buf,strerror(sysErr));
  48. }
  49. va_end(vl);
  50. return rc;
  51. }
  52. cmFs_t* _cmFileSysHandleToPtr( cmFileSysH_t h )
  53. {
  54. cmFs_t* p = (cmFs_t*)h.h;
  55. assert( p != NULL);
  56. return p;
  57. }
  58. cmFsRC_t _cmFileSysFinalize( cmFs_t* p )
  59. {
  60. cmFsRC_t rc = kOkFsRC;
  61. if( cmLHeapIsValid(p->heapH) )
  62. cmLHeapDestroy(&p->heapH);
  63. #ifdef OS_OSX
  64. if( p->p != NULL )
  65. if((rc = _cmOsxFileSysFinalize(p->p) ) != kOkFsRC )
  66. {
  67. _cmFileSysError(p,kOsxFailFsRC,0,"The OSX file system finalization failed.");
  68. return rc;
  69. }
  70. #endif
  71. #ifdef OS_LINUX
  72. if( p->p != NULL )
  73. if((rc = _cmLinuxFileSysFinalize(p->p) ) != kOkFsRC )
  74. {
  75. _cmFileSysError(p,kLinuxFailFsRC,0,"The Linux file system finalization failed.");
  76. return rc;
  77. }
  78. #endif
  79. cmMemPtrFree(&p);
  80. return rc;
  81. }
  82. cmFsRC_t cmFileSysInitialize( cmFileSysH_t* hp, cmCtx_t* ctx, const cmChar_t* appNameStr )
  83. {
  84. cmFs_t* p;
  85. cmFsRC_t rc;
  86. cmErr_t err;
  87. if((rc = cmFileSysFinalize(hp)) != kOkFsRC )
  88. return rc;
  89. cmErrSetup(&err,&ctx->rpt,"File System");
  90. if((p = cmMemAllocZ( cmFs_t, 1 )) == NULL )
  91. return cmErrMsg(&err,kMemAllocErrFsRC,"Unable to allocate the file system object.");
  92. cmErrClone(&p->err,&err);
  93. if(cmLHeapIsValid( p->heapH = cmLHeapCreate(1024,ctx)) == false )
  94. {
  95. rc = _cmFileSysError(p,kLHeapAllocErrFsRC,0,"Unable to allocate the linked heap.");
  96. goto errLabel;
  97. }
  98. p->appNameStr = cmLhAllocStr(p->heapH,appNameStr);
  99. hp->h = p;
  100. #ifdef OS_OSX
  101. if( (rc = _cmOsxFileSysInit(&p->p, p->heapH, &p->err)) != kOkFsRC )
  102. {
  103. rc = _cmFileSysError(p,kOsxFailFsRC,0,"OSX file system initialization failed.");
  104. goto errLabel;
  105. }
  106. const cmChar_t* dir = cmFsMakeFn(p->p->prefDir,appNameStr,NULL,NULL);
  107. // BUG?
  108. // we reuse p->p->prefDir here because the one returned by the platform
  109. // specific code is never released ... which isn't quite right either
  110. // See osx/cmFileSysOsx.c.
  111. p->p->prefDir = cmLhAllocStr(p->heapH,dir);
  112. cmFsFreeFn(dir);
  113. #endif
  114. #ifdef OS_LINUX
  115. if( (rc = _cmLinuxFileSysInit(&p->p, p->heapH, &p->err)) != kOkFsRC )
  116. {
  117. rc = _cmFileSysError(p,kLinuxFailFsRC,0,"Linux file system initialization failed.");
  118. goto errLabel;
  119. }
  120. else
  121. {
  122. #endif
  123. #ifdef OS_LINUX
  124. cmChar_t hidAppNameStr[ strlen(appNameStr) + 2 ];
  125. strcpy(hidAppNameStr,".");
  126. strcat(hidAppNameStr,appNameStr);
  127. p->p->prefDir = cmFileSysMakeFn( *hp, p->p->prefDir, hidAppNameStr, NULL, NULL );
  128. // the resource directory must exist before the program can start
  129. p->p->rsrcDir = cmFileSysMakeFn( *hp, p->p->rsrcDir, appNameStr, NULL, NULL );
  130. }
  131. #endif
  132. errLabel:
  133. if( rc != kOkFsRC )
  134. return _cmFileSysFinalize(p);
  135. return kOkFsRC;
  136. }
  137. cmFsRC_t cmFileSysFinalize( cmFileSysH_t* hp )
  138. {
  139. cmFsRC_t rc;
  140. if( hp==NULL || cmFileSysIsValid(*hp) == false )
  141. return kOkFsRC;
  142. cmFs_t* p = _cmFileSysHandleToPtr(*hp);
  143. if((rc = _cmFileSysFinalize(p)) != kOkFsRC )
  144. return rc;
  145. hp->h = NULL;
  146. return rc;
  147. }
  148. const cmChar_t* cmFileSysAppName( cmFileSysH_t h )
  149. {
  150. cmFs_t* p = _cmFileSysHandleToPtr(h);
  151. return p->appNameStr;
  152. }
  153. const cmChar_t* cmFileSysPrefsDir( cmFileSysH_t h )
  154. {
  155. cmFs_t* p = _cmFileSysHandleToPtr(h);
  156. #if defined OS_OSX || defined OS_LINUX
  157. return p->p->prefDir;
  158. #else
  159. return NULL;
  160. #endif
  161. }
  162. const cmChar_t* cmFileSysRsrcDir( cmFileSysH_t h )
  163. {
  164. cmFs_t* p = _cmFileSysHandleToPtr(h);
  165. #if defined OS_OSX || defined OS_LINUX
  166. return p->p->rsrcDir;
  167. #else
  168. return NULL;
  169. #endif
  170. }
  171. const cmChar_t* cmFileSysUserDir( cmFileSysH_t h )
  172. {
  173. cmFs_t* p = _cmFileSysHandleToPtr(h);
  174. #if defined OS_OSX || defined OS_LINUX
  175. return p->p->userDir;
  176. #else
  177. return NULL;
  178. #endif
  179. }
  180. bool cmFileSysIsValid( cmFileSysH_t h )
  181. { return h.h != NULL; }
  182. bool _cmFileSysIsDir( cmFs_t* p, const cmChar_t* dirStr )
  183. {
  184. struct stat s;
  185. errno = 0;
  186. if( stat(dirStr,&s) != 0 )
  187. {
  188. // if the dir does not exist
  189. if( errno == ENOENT )
  190. return false;
  191. _cmFileSysError( p, kStatFailFsRC, errno, "'stat' failed on '%s'",dirStr);
  192. return false;
  193. }
  194. return S_ISDIR(s.st_mode);
  195. }
  196. bool cmFileSysIsDir( cmFileSysH_t h, const cmChar_t* dirStr )
  197. {
  198. cmFs_t* p = _cmFileSysHandleToPtr(h);
  199. return _cmFileSysIsDir(p,dirStr);
  200. }
  201. bool _cmFileSysIsFile( cmFs_t* p, const cmChar_t* fnStr )
  202. {
  203. struct stat s;
  204. errno = 0;
  205. if( stat(fnStr,&s) != 0 )
  206. {
  207. // if the file does not exist
  208. if( errno == ENOENT )
  209. return false;
  210. _cmFileSysError( p, kStatFailFsRC, errno, "'stat' failed on '%s'.",fnStr);
  211. return false;
  212. }
  213. return S_ISREG(s.st_mode);
  214. }
  215. bool cmFileSysIsFile( cmFileSysH_t h, const cmChar_t* fnStr )
  216. {
  217. cmFs_t* p = _cmFileSysHandleToPtr(h);
  218. return _cmFileSysIsFile(p,fnStr);
  219. }
  220. bool _cmFileSysIsLink( cmFs_t* p, const cmChar_t* fnStr )
  221. {
  222. struct stat s;
  223. errno = 0;
  224. if( lstat(fnStr,&s) != 0 )
  225. {
  226. // if the file does not exist
  227. if( errno == ENOENT )
  228. return false;
  229. _cmFileSysError( p, kStatFailFsRC, errno, "'stat' failed on '%s'.",fnStr);
  230. return false;
  231. }
  232. return S_ISLNK(s.st_mode);
  233. }
  234. bool cmFileSysIsLink( cmFileSysH_t h, const cmChar_t* fnStr )
  235. {
  236. cmFs_t* p = _cmFileSysHandleToPtr(h);
  237. return _cmFileSysIsLink(p,fnStr);
  238. }
  239. bool _cmFileSysIsSocket( cmFs_t* p, const cmChar_t* fnStr )
  240. {
  241. struct stat s;
  242. errno = 0;
  243. if( stat(fnStr,&s) != 0 )
  244. {
  245. // if the file does not exist
  246. if( errno == ENOENT )
  247. return false;
  248. _cmFileSysError( p, kStatFailFsRC, errno, "'stat' failed on '%s'.",fnStr);
  249. return false;
  250. }
  251. return S_ISSOCK(s.st_mode);
  252. }
  253. bool _cmFileSysConcat( cmChar_t* rp, unsigned rn, char sepChar, const cmChar_t* suffixStr )
  254. {
  255. unsigned m = strlen(rp);
  256. // m==0 if no sep needs to be inserted or removed
  257. //if( m == 0 )
  258. // return false;
  259. if( m != 0 )
  260. {
  261. // if a sep char needs to be inserted
  262. if( rp[m-1] != sepChar && suffixStr[0] != sepChar )
  263. {
  264. assert((m+1)<rn);
  265. if((m+1)>=rn)
  266. return false;
  267. rp[m] = sepChar;
  268. rp[m+1]= 0;
  269. ++m;
  270. }
  271. else
  272. // if a sep char needs to be removed
  273. if( rp[m-1] == sepChar && suffixStr[0] == sepChar )
  274. {
  275. rp[m-1] = 0;
  276. --m;
  277. }
  278. }
  279. assert( rn>=m && strlen(rp)+strlen(suffixStr) <= rn );
  280. strncat(rp,suffixStr,rn-m);
  281. return true;
  282. }
  283. const cmChar_t* cmFileSysVMakeFn( cmFileSysH_t h, const cmChar_t* dir, const cmChar_t* fn, const cmChar_t* ext, va_list vl )
  284. {
  285. cmFsRC_t rc = kOkFsRC;
  286. cmChar_t* rp = NULL;
  287. const cmChar_t* dp = NULL;
  288. unsigned n = 0;
  289. cmFs_t* p = _cmFileSysHandleToPtr(h);
  290. char pathSep = cmPathSeparatorChar[0];
  291. char extSep = '.';
  292. va_list vl_t;
  293. va_copy(vl_t,vl);
  294. assert( fn != NULL );
  295. // get prefix directory length
  296. if( dir != NULL )
  297. n += strlen(dir) + 1; // add 1 for ending sep
  298. // get file name length
  299. n += strlen(fn);
  300. // get extension length
  301. if( ext != NULL )
  302. n += strlen(ext) + 1; // add 1 for period
  303. // get length of all var args dir's
  304. while( (dp = va_arg(vl,const cmChar_t*)) != NULL )
  305. n += strlen(dp) + 1; // add 1 for ending sep
  306. // add 1 for terminating zero and allocate memory
  307. if((rp = cmLHeapAllocZ( p->heapH, n+1 )) == NULL )
  308. {
  309. rc = _cmFileSysError(p,kMemAllocErrFsRC,0,"Unable to allocate file name memory.");
  310. goto errLabel;
  311. }
  312. va_copy(vl,vl_t);
  313. rp[n] = 0;
  314. rp[0] = 0;
  315. // copy out the prefix dir
  316. if( dir != NULL )
  317. strncat(rp,dir,n-strlen(rp));
  318. // copy out ecmh of the var arg's directories
  319. while((dp = va_arg(vl,const cmChar_t*)) != NULL )
  320. if(!_cmFileSysConcat(rp,n,pathSep,dp) )
  321. {
  322. assert(0);
  323. rc = _cmFileSysError(p,kAssertFailFsRC,0,"Assert failed.");
  324. goto errLabel;
  325. }
  326. // copy out the file name
  327. if(!_cmFileSysConcat(rp,n,pathSep,fn))
  328. {
  329. assert(0);
  330. rc = _cmFileSysError(p,kAssertFailFsRC,0,"Assert failed.");
  331. goto errLabel;
  332. }
  333. // copy out the extension
  334. if( ext != NULL )
  335. if(!_cmFileSysConcat(rp,n,extSep,ext))
  336. {
  337. assert(0);
  338. rc = _cmFileSysError(p,kAssertFailFsRC,0,"Assert failed.");
  339. goto errLabel;
  340. }
  341. assert(strlen(rp)<=n);
  342. errLabel:
  343. if( rc != kOkFsRC && rp != NULL )
  344. cmLHeapFree(p->heapH, rp );
  345. return rp;
  346. }
  347. const cmChar_t* cmFileSysMakeFn( cmFileSysH_t h, const cmChar_t* dir, const cmChar_t* fn, const cmChar_t* ext, ... )
  348. {
  349. va_list vl;
  350. va_start(vl,ext);
  351. const cmChar_t* retPtr = cmFileSysVMakeFn(h,dir,fn,ext,vl);
  352. va_end(vl);
  353. return retPtr;
  354. }
  355. void cmFileSysFreeFn( cmFileSysH_t h, const cmChar_t* fn )
  356. {
  357. cmFs_t* p = _cmFileSysHandleToPtr(h);
  358. if( fn == NULL )
  359. return;
  360. cmLHeapFree(p->heapH, (void*)fn);
  361. }
  362. cmFsRC_t cmFileSysMkDir( cmFileSysH_t h, const cmChar_t* dir )
  363. {
  364. cmFs_t* p = _cmFileSysHandleToPtr(h);
  365. if( mkdir(dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0 )
  366. return _cmFileSysError( p, kMkDirFailFsRC, errno, "The attempt to create the directory '%s' failed.",dir);
  367. return kOkFsRC;
  368. }
  369. cmFsRC_t cmFileSysMkDirAll( cmFileSysH_t h, const cmChar_t* dir )
  370. {
  371. cmFsRC_t rc = kOkFsRC;
  372. cmFs_t* p = _cmFileSysHandleToPtr(h);
  373. cmChar_t** a = NULL;
  374. unsigned i;
  375. if((a = cmFileSysDirParts(h,dir)) == NULL )
  376. return _cmFileSysError(p, kInvalidDirFsRC, 0, "The directory '%s' could not be parsed.",cmStringNullGuard(dir));
  377. for(i=0; rc==kOkFsRC && a[i]!=NULL; ++i)
  378. {
  379. cmChar_t* d = cmFileSysFormDir(h,a,i+1);
  380. if( cmFileSysIsDir(h,d)==false )
  381. if((rc = cmFileSysMkDir(h,d)) != kOkFsRC )
  382. break;
  383. cmFileSysFreeDir(h,d);
  384. }
  385. cmFileSysFreeDirParts(h,a);
  386. return rc;
  387. }
  388. cmFileSysPathPart_t* cmFileSysPathParts( cmFileSysH_t h, const cmChar_t* pathStr )
  389. {
  390. int n = 0; // char's in pathStr
  391. int dn = 0; // char's in the dir part
  392. int fn = 0; // char's in the name part
  393. int en = 0; // char's in the ext part
  394. cmChar_t* cp = NULL;
  395. cmFileSysPathPart_t* rp = NULL;
  396. cmFs_t* p = _cmFileSysHandleToPtr(h);
  397. if( pathStr==NULL )
  398. return NULL;
  399. // skip leading white space
  400. while( *pathStr )
  401. {
  402. if( isspace(*pathStr ) )
  403. ++pathStr;
  404. else
  405. break;
  406. }
  407. // get the length of pathStr
  408. if((n = strlen(pathStr)) == 0 )
  409. return NULL;
  410. // remove trailing spaces
  411. for(; n>0; --n)
  412. {
  413. if( isspace(pathStr[n-1]) )
  414. --n;
  415. else
  416. break;
  417. }
  418. //
  419. if( n == 0 )
  420. return NULL;
  421. char buf[n+1];
  422. buf[n] = 0;
  423. // Get the last word (which may be a file name) from pathStr.
  424. // (pathStr must be copied into a buf because basename()
  425. // is allowed to change the values in its arg.)
  426. strncpy(buf,pathStr,n);
  427. cp = basename(buf);
  428. if( cp != NULL )
  429. {
  430. cmChar_t* ep;
  431. // does the last word have a period in it
  432. if( (ep = strchr(cp,'.')) != NULL )
  433. {
  434. *ep = 0; // end the file name at the period
  435. ++ep; // set the ext marker
  436. en = strlen(ep); // get the length of the ext
  437. }
  438. fn = strlen(cp); //get the length of the file name
  439. }
  440. // Get the directory part.
  441. // ( pathStr must be copied into a buf because dirname()
  442. // is allowed to change the values in its arg.)
  443. strncpy(buf,pathStr,n);
  444. // if the last char in pathStr[] is '/' then the whole string is a dir.
  445. // (this is not the answer that dirname() and basename() would give).
  446. if( pathStr[n-1] == cmPathSeparatorChar[0] )
  447. {
  448. fn = 0;
  449. en = 0;
  450. dn = n;
  451. cp = buf;
  452. }
  453. else
  454. {
  455. cp = dirname(buf);
  456. }
  457. if( cp != NULL )
  458. dn = strlen(cp);
  459. // get the total size of the returned memory. (add 3 for ecmh possible terminating zero)
  460. n = sizeof(cmFileSysPathPart_t) + dn + fn + en + 3;
  461. // alloc memory
  462. if((rp = (cmFileSysPathPart_t*)cmLHeapAllocZ( p->heapH, n )) == NULL )
  463. {
  464. _cmFileSysError( p, kLHeapAllocErrFsRC, 0, "Unable to allocate the file system path part record for '%s'.",pathStr);
  465. return NULL;
  466. }
  467. // set the return pointers for ecmh of the parts
  468. rp->dirStr = (const cmChar_t* )(rp + 1);
  469. rp->fnStr = rp->dirStr + dn + 1;
  470. rp->extStr = rp->fnStr + fn + 1;
  471. // if there is a directory part
  472. if( dn>0 )
  473. strcpy((cmChar_t*)rp->dirStr,cp);
  474. else
  475. rp->dirStr = NULL;
  476. if( fn || en )
  477. {
  478. // Get the trailing word again.
  479. // pathStr must be copied into a buf because basename() may
  480. // is allowed to change the values in its arg.
  481. strncpy(buf,pathStr,n);
  482. cp = basename(buf);
  483. if( cp != NULL )
  484. {
  485. cmChar_t* ep;
  486. if( (ep = strchr(cp,'.')) != NULL )
  487. {
  488. *ep = 0;
  489. ++ep;
  490. assert( strlen(ep) == en );
  491. strcpy((cmChar_t*)rp->extStr,ep);
  492. }
  493. assert( strlen(cp) == fn );
  494. if(fn)
  495. strcpy((cmChar_t*)rp->fnStr,cp);
  496. }
  497. }
  498. if( fn == 0 )
  499. rp->fnStr = NULL;
  500. if( en == 0 )
  501. rp->extStr = NULL;
  502. return rp;
  503. }
  504. void cmFileSysFreePathParts( cmFileSysH_t h, cmFileSysPathPart_t* pp )
  505. {
  506. if( pp == NULL )
  507. return;
  508. cmFs_t* p = _cmFileSysHandleToPtr(h);
  509. cmLHeapFree(p->heapH, (void*)pp );
  510. }
  511. cmChar_t** cmFileSysDirParts( cmFileSysH_t h, const cmChar_t* dirStr )
  512. {
  513. cmFs_t* p = _cmFileSysHandleToPtr(h);
  514. const cmChar_t* s = dirStr;
  515. const cmChar_t* ep = dirStr + strlen(dirStr);
  516. char pathSep = cmPathSeparatorChar[0];
  517. unsigned n = 2;
  518. unsigned i = 0;
  519. // skip leading white space or pathsep
  520. while( isspace(*s) && s < ep )
  521. ++s;
  522. // if the directory string is empty
  523. if( s >= ep )
  524. return NULL;
  525. // set the beginning of the input dirStr past any leading white space
  526. dirStr = s;
  527. // count the number of dir segments - this might overcount the
  528. // number of segments if there are multiple repeated path seperator
  529. // char's - but this is ok because 'n' is only used to determine
  530. // the size of the returned array - which will simply have some
  531. // NULL entries at the end.
  532. for(; s < ep; ++s )
  533. if( *s == pathSep )
  534. ++n;
  535. // allocate the array
  536. cmChar_t** a = cmLhAllocZ(p->heapH,cmChar_t*,n);
  537. // reset the cur location to the begin of the buf
  538. s = dirStr;
  539. // if the path starts at the root
  540. if( *s == pathSep )
  541. {
  542. a[0] = cmPathSeparatorChar; // cmPathSeparatorChar is a static string in cmGlobal.h
  543. i = 1;
  544. ++s;
  545. }
  546. for(; i<n && s<ep; ++i)
  547. {
  548. const cmChar_t* s1;
  549. if(( s1 = strchr(s,pathSep)) == NULL )
  550. s1 = ep;
  551. if( s1!=s )
  552. {
  553. unsigned sn = (s1 - s)+1;
  554. a[i] = cmLhAlloc(p->heapH,cmChar_t,sn);
  555. strncpy(a[i],s,sn-1);
  556. a[i][sn-1] = 0;
  557. }
  558. s = s1+1;
  559. }
  560. return a;
  561. }
  562. void cmFileSysFreeDirParts( cmFileSysH_t h, cmChar_t** dirStrArray )
  563. {
  564. if( dirStrArray == NULL )
  565. return;
  566. cmFs_t* p = _cmFileSysHandleToPtr(h);
  567. unsigned i;
  568. for(i=0; dirStrArray[i]!=NULL; ++i)
  569. {
  570. // cmPathSeparatorChar is statically alloc'd in cmGlobal.h
  571. if( dirStrArray[i] != cmPathSeparatorChar )
  572. cmLHeapFree(p->heapH,dirStrArray[i]);
  573. }
  574. cmLHeapFree(p->heapH, (void*)dirStrArray );
  575. }
  576. unsigned cmFileSysDirPartsCount(cmFileSysH_t h, cmChar_t** dirStrArray )
  577. {
  578. unsigned i = 0;
  579. if( dirStrArray == NULL )
  580. return 0;
  581. while(dirStrArray[i] != NULL )
  582. ++i;
  583. return i;
  584. }
  585. cmChar_t* cmFileSysFormDir( cmFileSysH_t h, cmChar_t** a, unsigned m )
  586. {
  587. cmFs_t* p = _cmFileSysHandleToPtr(h);
  588. unsigned n;
  589. unsigned i;
  590. // determine the length of the return string
  591. for(i=0,n=0; a[i]!=NULL && i<m; ++i)
  592. n += strlen(a[i]) + strlen(cmPathSeparatorChar);
  593. if( i<m && a[i] == NULL )
  594. {
  595. _cmFileSysError(p,kInvalidDirFsRC,0,"cmFileSysFormDir() cannot form a directory string from %i parts when only %i exist.",m,i);
  596. return NULL;
  597. }
  598. n += 1;
  599. // allocate the return string
  600. cmChar_t* r = cmLhAllocZ(p->heapH,cmChar_t,n);
  601. const cmChar_t* ep = r + n;
  602. // form the return string
  603. for(i=0; a[i]!=NULL && i<m; ++i)
  604. {
  605. strcat(r,a[i]);
  606. if( strcmp(a[i],cmPathSeparatorChar)!=0 && a[i+1]!=NULL )
  607. strcat(r,cmPathSeparatorChar);
  608. assert( r + strlen(r) <= ep );
  609. }
  610. return r;
  611. }
  612. void cmFileSysFreeDir( cmFileSysH_t h, const cmChar_t* dir )
  613. {
  614. if( dir == NULL )
  615. return;
  616. cmFs_t* p = _cmFileSysHandleToPtr(h);
  617. cmLHeapFree(p->heapH,(void*)dir);
  618. }
  619. typedef struct
  620. {
  621. cmFs_t* p;
  622. unsigned filterFlags;
  623. cmFileSysDirEntry_t* rp;
  624. cmChar_t* dataPtr;
  625. cmChar_t* endPtr;
  626. unsigned entryCnt;
  627. unsigned entryIdx;
  628. unsigned dataByteCnt;
  629. unsigned passIdx;
  630. } cmFileSysDeRecd_t;
  631. cmFsRC_t _cmFileSysDirGetEntries( cmFileSysDeRecd_t* drp, const cmChar_t* dirStr )
  632. {
  633. cmFsRC_t rc = kOkFsRC;
  634. DIR* dirp = NULL;
  635. struct dirent* dp = NULL;
  636. char curDirPtr[] = "./";
  637. unsigned dn = 0;
  638. if( dirStr == NULL || strlen(dirStr) == 0 )
  639. dirStr = curDirPtr;
  640. if( _cmFileSysIsDir(drp->p,dirStr) == false )
  641. return rc;
  642. unsigned fnCharCnt= strlen(dirStr) + PATH_MAX;
  643. char fn[ fnCharCnt + 1 ];
  644. // copy the directory into fn[] ...
  645. fn[0] =0;
  646. fn[fnCharCnt] = 0;
  647. strcpy(fn,dirStr);
  648. assert( strlen(fn)+2 < fnCharCnt );
  649. // ... and be sure that it is terminated with a path sep char
  650. if( fn[ strlen(fn)-1 ] != cmPathSeparatorChar[0] )
  651. strcat(fn,cmPathSeparatorChar);
  652. // file names will be appended to the path at this location
  653. unsigned fni = strlen(fn);
  654. // open the directory
  655. if((dirp = opendir(dirStr)) == NULL)
  656. {
  657. rc = _cmFileSysError(drp->p,kOpenDirFailFsRC,errno,"Unable to open the directory:'%s'.",dirStr);
  658. goto errLabel;
  659. }
  660. // get the next directory entry
  661. while((dp = readdir(dirp)) != NULL )
  662. {
  663. // validate d_name
  664. if( (dp->d_name != NULL) && ((dn = strlen(dp->d_name)) > 0) )
  665. {
  666. unsigned flags = 0;
  667. // handle cases where d_name begins with '.'
  668. if( dp->d_name[0] == '.' )
  669. {
  670. if( strcmp(dp->d_name,".") == 0 )
  671. {
  672. if( cmIsFlag(drp->filterFlags,kCurDirFsFl) == false )
  673. continue;
  674. flags |= kCurDirFsFl;
  675. }
  676. if( strcmp(dp->d_name,"..") == 0 )
  677. {
  678. if( cmIsFlag(drp->filterFlags,kParentDirFsFl) == false )
  679. continue;
  680. flags |= kParentDirFsFl;
  681. }
  682. if( flags == 0 )
  683. {
  684. if( cmIsFlag(drp->filterFlags,kInvisibleFsFl) == false )
  685. continue;
  686. flags |= kInvisibleFsFl;
  687. }
  688. }
  689. fn[fni] = 0;
  690. strncat( fn, dp->d_name, fnCharCnt-fni );
  691. unsigned fnN = strlen(fn);
  692. // if the filename is too long for the buffer
  693. if( fnN > fnCharCnt )
  694. {
  695. rc = _cmFileSysError(drp->p, kFnTooLongFsRC, errno, "The directory entry:'%s' was too long to be processed.",dp->d_name);
  696. goto errLabel;
  697. }
  698. // is a link
  699. if( _cmFileSysIsLink(drp->p,fn) )
  700. {
  701. if( cmIsFlag(drp->filterFlags,kLinkFsFl) == false )
  702. continue;
  703. flags |= kLinkFsFl;
  704. if( cmIsFlag(drp->filterFlags,kRecurseLinksFsFl) )
  705. if((rc = _cmFileSysDirGetEntries(drp,fn)) != kOkFsRC )
  706. goto errLabel;
  707. }
  708. else
  709. {
  710. // is the entry a file
  711. if( _cmFileSysIsFile(drp->p,fn) )
  712. {
  713. if( cmIsFlag(drp->filterFlags,kFileFsFl)==false )
  714. continue;
  715. flags |= kFileFsFl;
  716. }
  717. else
  718. {
  719. // is the entry a dir
  720. if( _cmFileSysIsDir(drp->p,fn) )
  721. {
  722. if( cmIsFlag(drp->filterFlags,kDirFsFl) == false)
  723. continue;
  724. flags |= kDirFsFl;
  725. if( cmIsFlag(drp->filterFlags,kRecurseFsFl) )
  726. if((rc = _cmFileSysDirGetEntries(drp,fn)) != kOkFsRC )
  727. goto errLabel;
  728. }
  729. else
  730. {
  731. continue;
  732. }
  733. }
  734. }
  735. //assert(flags != 0);
  736. if( drp->passIdx == 0 )
  737. {
  738. ++drp->entryCnt;
  739. // add 1 for the name terminating zero
  740. drp->dataByteCnt += sizeof(cmFileSysDirEntry_t) + 1;
  741. if( cmIsFlag(drp->filterFlags,kFullPathFsFl) )
  742. drp->dataByteCnt += fnN;
  743. else
  744. drp->dataByteCnt += dn;
  745. }
  746. else
  747. {
  748. assert( drp->passIdx == 1 );
  749. assert( drp->entryIdx < drp->entryCnt );
  750. unsigned n = 0;
  751. if( cmIsFlag(drp->filterFlags,kFullPathFsFl) )
  752. {
  753. n = fnN+1;
  754. assert( drp->dataPtr + n <= drp->endPtr );
  755. strcpy(drp->dataPtr,fn);
  756. }
  757. else
  758. {
  759. n = dn+1;
  760. assert( drp->dataPtr + n <= drp->endPtr );
  761. strcpy(drp->dataPtr,dp->d_name);
  762. }
  763. drp->rp[ drp->entryIdx ].flags = flags;
  764. drp->rp[ drp->entryIdx ].name = drp->dataPtr;
  765. drp->dataPtr += n;
  766. assert( drp->dataPtr <= drp->endPtr);
  767. ++drp->entryIdx;
  768. }
  769. }
  770. }
  771. errLabel:
  772. if( dirp != NULL )
  773. closedir(dirp);
  774. return rc;
  775. }
  776. cmFileSysDirEntry_t* cmFileSysDirEntries( cmFileSysH_t h, const cmChar_t* dirStr, unsigned filterFlags, unsigned* dirEntryCntPtr )
  777. {
  778. cmFsRC_t rc = kOkFsRC;
  779. cmFileSysDeRecd_t r;
  780. memset(&r,0,sizeof(r));
  781. r.p = _cmFileSysHandleToPtr(h);
  782. r.filterFlags = filterFlags;
  783. assert( dirEntryCntPtr != NULL );
  784. *dirEntryCntPtr = 0;
  785. for(r.passIdx=0; r.passIdx<2; ++r.passIdx)
  786. {
  787. if((rc = _cmFileSysDirGetEntries( &r, dirStr )) != kOkFsRC )
  788. goto errLabel;
  789. if( r.passIdx == 0 && r.dataByteCnt>0 )
  790. {
  791. // allocate memory to hold the return values
  792. if(( r.rp = (cmFileSysDirEntry_t *)cmLHeapAllocZ( r.p->heapH, r.dataByteCnt )) == NULL )
  793. {
  794. rc= _cmFileSysError( r.p, kMemAllocErrFsRC, 0, "Unable to allocate %i bytes of dir entry memory.",r.dataByteCnt);
  795. goto errLabel;
  796. }
  797. r.dataPtr = (cmChar_t*)(r.rp + r.entryCnt);
  798. r.endPtr = ((cmChar_t*)r.rp) + r.dataByteCnt;
  799. }
  800. }
  801. errLabel:
  802. if( rc == kOkFsRC )
  803. {
  804. assert( r.entryIdx == r.entryCnt );
  805. *dirEntryCntPtr = r.entryCnt;
  806. }
  807. else
  808. {
  809. if( r.rp != NULL )
  810. cmLHeapFree(r.p->heapH,r.rp);
  811. r.rp = NULL;
  812. }
  813. return r.rp;
  814. }
  815. void cmFileSysDirFreeEntries( cmFileSysH_t h, cmFileSysDirEntry_t* dp )
  816. {
  817. cmFs_t* p = _cmFileSysHandleToPtr(h);
  818. if( dp != NULL )
  819. cmLHeapFree(p->heapH,dp);
  820. }
  821. cmFsRC_t cmFileSysErrorCode( cmFileSysH_t h )
  822. {
  823. cmFs_t* p = _cmFileSysHandleToPtr(h);
  824. return cmErrLastRC(&p->err);
  825. }
  826. //
  827. //======================================================================================================
  828. // Begin global versions
  829. //
  830. cmFileSysH_t _cmFsH = { NULL };
  831. cmFsRC_t cmFsInitialize( cmCtx_t* ctx, const cmChar_t* appNameStr )
  832. { return cmFileSysInitialize(&_cmFsH,ctx,appNameStr); }
  833. cmFsRC_t cmFsFinalize()
  834. { return cmFileSysFinalize(&_cmFsH); }
  835. const cmChar_t* cmFsAppName()
  836. { return cmFileSysAppName(_cmFsH); }
  837. const cmChar_t* cmFsPrefsDir()
  838. { return cmFileSysPrefsDir(_cmFsH); }
  839. const cmChar_t* cmFsRsrcDir()
  840. { return cmFileSysRsrcDir(_cmFsH); }
  841. const cmChar_t* cmFsUserDir()
  842. { return cmFileSysUserDir(_cmFsH); }
  843. bool cmFsIsDir( const cmChar_t* dirStr )
  844. { return cmFileSysIsDir(_cmFsH,dirStr); }
  845. bool cmFsIsFile( const cmChar_t* fnStr )
  846. { return cmFileSysIsFile(_cmFsH,fnStr); }
  847. bool cmFsIsLink( const cmChar_t* fnStr )
  848. { return cmFileSysIsLink(_cmFsH,fnStr); }
  849. const cmChar_t* cmFsVMakeFn( const cmChar_t* dirPrefix, const cmChar_t* fn, const cmChar_t* ext, va_list vl )
  850. { return cmFileSysVMakeFn(_cmFsH,dirPrefix,fn,ext,vl); }
  851. const cmChar_t* cmFsMakeFn( const cmChar_t* dirPrefix, const cmChar_t* fn, const cmChar_t* ext, ... )
  852. {
  853. va_list vl;
  854. va_start(vl,ext);
  855. const cmChar_t* retPtr = cmFsVMakeFn(dirPrefix,fn,ext,vl);
  856. va_end(vl);
  857. return retPtr;
  858. }
  859. void cmFsFreeFn( const cmChar_t* fn )
  860. { cmFileSysFreeFn(_cmFsH, fn); }
  861. cmFsRC_t cmFsMkDir( const cmChar_t* dir )
  862. { return cmFileSysMkDir(_cmFsH,dir); }
  863. cmFsRC_t cmFsMkDirAll( const cmChar_t* dir )
  864. { return cmFileSysMkDirAll(_cmFsH,dir); }
  865. cmFileSysPathPart_t* cmFsPathParts( const cmChar_t* pathNameStr )
  866. { return cmFileSysPathParts(_cmFsH,pathNameStr); }
  867. void cmFsFreePathParts( cmFileSysPathPart_t* p )
  868. { cmFileSysFreePathParts(_cmFsH,p); }
  869. cmChar_t** cmFsDirParts( const cmChar_t* dirStr )
  870. { return cmFileSysDirParts(_cmFsH,dirStr); }
  871. void cmFsFreeDirParts( cmChar_t** dirStrArray )
  872. { cmFileSysFreeDirParts(_cmFsH,dirStrArray); }
  873. unsigned cmFsDirPartsCount( cmChar_t** dirStrArray )
  874. { return cmFileSysDirPartsCount(_cmFsH, dirStrArray); }
  875. cmChar_t* cmFsFormDir( cmChar_t** dirStrArray, unsigned n )
  876. { return cmFileSysFormDir(_cmFsH,dirStrArray,n); }
  877. void cmFsFreeDir( const cmChar_t* dir )
  878. { cmFileSysFreeDir(_cmFsH,dir); }
  879. cmFileSysDirEntry_t* cmFsDirEntries( const cmChar_t* dirStr, unsigned includeFlags, unsigned* dirEntryCntPtr )
  880. { return cmFileSysDirEntries(_cmFsH,dirStr,includeFlags,dirEntryCntPtr); }
  881. void cmFsDirFreeEntries( cmFileSysDirEntry_t* p )
  882. { cmFileSysDirFreeEntries(_cmFsH,p); }
  883. cmFsRC_t cmFsErrorCode()
  884. { return cmFileSysErrorCode(_cmFsH); }
  885. // end global version
  886. //======================================================================================================
  887. //
  888. //{ { label:cmFileSysEx }
  889. //(
  890. //
  891. // cmFileSysTest() function gives usage and testing examples
  892. // for some of the cmFileSys functions.
  893. // Note that the HOME_DIR macro should be set to your true
  894. // $HOME directroy and SRC_DIR should be set to any existing
  895. // and accessible directory.
  896. //
  897. //)
  898. //(
  899. #if defined(OS_OSX)
  900. #define HOME_DIR "/Users/kevin"
  901. #else
  902. #define HOME_DIR "/home/kevin"
  903. #endif
  904. #define SRC_DIR HOME_DIR"/src"
  905. void _cmFileSysTestFnParser(
  906. cmFileSysH_t h,
  907. cmRpt_t* rpt,
  908. const cmChar_t* fn );
  909. cmFsRC_t cmFileSysTest( cmCtx_t* ctx )
  910. {
  911. // The global heap manager must have been initialized
  912. // via cmMdInitialize() prior to running this function.
  913. cmFsRC_t rc = kOkFsRC;
  914. cmFileSysH_t h = cmFileSysNullHandle;
  915. const char dir0[] = SRC_DIR;
  916. const char dir1[] = HOME_DIR"/blah";
  917. const char file0[] = HOME_DIR"/.emacs";
  918. const char file1[] = HOME_DIR"/blah.txt";
  919. const char not[] = " not ";
  920. const char e[] = " ";
  921. bool fl = false;
  922. const cmChar_t* fn = NULL;
  923. // Initialize the file system.
  924. if((rc = cmFileSysInitialize(&h,ctx,"fs_test")) != kOkFsRC )
  925. return rc;
  926. //----------------------------------------------------------
  927. // Print the standard directories
  928. //
  929. printf("Prefs Dir:%s\n",cmFsPrefsDir());
  930. printf("Rsrc Dir: %s\n",cmFsRsrcDir());
  931. printf("User Dir: %s\n",cmFsUserDir());
  932. //----------------------------------------------------------
  933. // Run the file system type checker
  934. //
  935. fl = cmFileSysIsDir(h,dir0);
  936. printf("'%s' is%sa directory.\n",dir0, (fl ? e : not));
  937. fl = cmFileSysIsDir(h,dir1);
  938. printf("'%s' is%sa directory.\n",dir1, (fl ? e : not));
  939. fl = cmFileSysIsFile(h,file0);
  940. printf("'%s' is%sa file.\n",file0, (fl ? e : not));
  941. fl = cmFileSysIsFile(h,file1);
  942. printf("'%s' is%sa file.\n",file1, (fl ? e : not));
  943. //----------------------------------------------------------
  944. // Test the file name creation functions
  945. //
  946. if((fn = cmFileSysMakeFn(h,HOME_DIR,"cmFileSys",
  947. "c","src","cm","src",NULL)) != NULL)
  948. {
  949. printf("File:'%s'\n",fn);
  950. }
  951. cmFileSysFreeFn(h,fn);
  952. if((fn = cmFileSysMakeFn(h,HOME_DIR,"cmFileSys",
  953. ".c","/src/","/cm/","/src/",NULL)) != NULL )
  954. {
  955. printf("File:'%s'\n",fn);
  956. }
  957. cmFileSysFreeFn(h,fn);
  958. //----------------------------------------------------------
  959. // Test the file name parsing functions
  960. //
  961. _cmFileSysTestFnParser(h,&ctx->rpt,
  962. HOME_DIR"/src/cm/src/cmFileSys.c");
  963. _cmFileSysTestFnParser(h,&ctx->rpt,
  964. HOME_DIR"/src/cm/src/cmFileSys");
  965. _cmFileSysTestFnParser(h,&ctx->rpt,
  966. HOME_DIR"/src/cm/src/cmFileSys/");
  967. _cmFileSysTestFnParser(h,&ctx->rpt,"cmFileSys.c");
  968. _cmFileSysTestFnParser(h,&ctx->rpt,"/");
  969. _cmFileSysTestFnParser(h,&ctx->rpt," ");
  970. //----------------------------------------------------------
  971. // Test the directory tree walking routines.
  972. //
  973. cmRptPrintf(&ctx->rpt,"Dir Entry Test:\n");
  974. cmFileSysDirEntry_t* dep;
  975. unsigned dirEntCnt;
  976. unsigned filterFlags = kDirFsFl
  977. | kFileFsFl
  978. | kRecurseFsFl
  979. | kFullPathFsFl;
  980. if((dep = cmFileSysDirEntries(h,SRC_DIR"/doc",filterFlags,
  981. &dirEntCnt)) != NULL)
  982. {
  983. unsigned i;
  984. for(i=0; i<dirEntCnt; ++i)
  985. cmRptPrintf(&ctx->rpt,"%s\n",dep[i].name);
  986. cmFileSysDirFreeEntries(h,dep);
  987. }
  988. //----------------------------------------------------------
  989. // Test the directory parsing/building routines.
  990. //
  991. cmRptPrintf(&ctx->rpt,"Dir Parsing routings:\n");
  992. cmChar_t** a;
  993. unsigned j;
  994. for(j=0; j<2; ++j)
  995. {
  996. const cmChar_t* dstr = dir0 + j;
  997. if((a = cmFileSysDirParts(h,dstr)) == NULL)
  998. cmRptPrint(&ctx->rpt,"cmFileSysDirParts() failed.\n");
  999. else
  1000. {
  1001. unsigned i;
  1002. cmRptPrintf(&ctx->rpt,"Input:%s\n",dstr);
  1003. for(i=0; a[i]!=NULL; ++i)
  1004. cmRptPrintf(&ctx->rpt,"%i : %s\n",i,a[i]);
  1005. cmChar_t* d;
  1006. if((d = cmFileSysFormDir(h,a,
  1007. cmFileSysDirPartsCount(h,a))) != NULL )
  1008. {
  1009. cmRptPrintf(&ctx->rpt,"Reformed:%s\n",d);
  1010. }
  1011. cmFileSysFreeDirParts(h,a);
  1012. }
  1013. }
  1014. //----------------------------------------------------------
  1015. // Test the extended mkdir routine.
  1016. //
  1017. if( cmFileSysMkDirAll(h, HOME_DIR"/temp/doc/doc" )!=kOkFsRC )
  1018. {
  1019. cmRptPrint(&ctx->rpt,"cmFileSysMkDirAll() failed.\n");
  1020. }
  1021. // finalize the file system
  1022. if((rc = cmFileSysFinalize(&h)) != kOkFsRC )
  1023. return rc;
  1024. cmRptPrintf(&ctx->rpt,"File Test done\n");
  1025. return rc;
  1026. }
  1027. // Parse a file name and print the results.
  1028. // Called by cmFileSysTest().
  1029. void _cmFileSysTestFnParser(
  1030. cmFileSysH_t h,
  1031. cmRpt_t* rpt,
  1032. const cmChar_t* fn )
  1033. {
  1034. cmFileSysPathPart_t* pp;
  1035. cmRptPrintf(rpt,"Fn Parse Test:%s\n",fn);
  1036. if((pp = cmFileSysPathParts(h,fn)) != NULL )
  1037. {
  1038. if(pp->dirStr != NULL)
  1039. cmRptPrintf(rpt,"Dir:%s\n",pp->dirStr);
  1040. if(pp->fnStr != NULL)
  1041. cmRptPrintf(rpt,"Fn:%s\n",pp->fnStr);
  1042. if(pp->extStr != NULL )
  1043. cmRptPrintf(rpt,"Ext:%s\n",pp->extStr);
  1044. cmFileSysFreePathParts(h,pp);
  1045. }
  1046. cmRptPrintf(rpt,"\n");
  1047. }
  1048. //)
  1049. //}