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.

cmFileSysLinux.c 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "cmFileSysLinux.h"
  11. #include <glob.h>
  12. //http://developer.apple.com/library/mac/#qa/qa1549/_index.html
  13. cmChar_t* _cmCreatePathByExpandingTildePath( _cmFsLinux_t* p, const char* path )
  14. {
  15. glob_t globbuf;
  16. char **v;
  17. char *expandedPath = NULL, *result = NULL;
  18. assert(path != NULL);
  19. if (glob(path, GLOB_TILDE, NULL, &globbuf) == 0) //success
  20. {
  21. v = globbuf.gl_pathv; //list of matched pathnames
  22. expandedPath = v[0]; //number of matched pathnames, gl_pathc == 1
  23. result = cmLhAllocZ(p->lhH,cmChar_t,strlen(expandedPath) + 1);
  24. //result = (char*)calloc(1, strlen(expandedPath) + 1); //the extra char is for the null-termination
  25. if(result)
  26. strncpy(result, expandedPath, strlen(expandedPath) + 1); //copy the null-termination as well
  27. globfree(&globbuf);
  28. }
  29. return result;
  30. }
  31. cmFsRC_t _cmLinuxFileSysInit( _cmFsLinux_t** pp, cmLHeapH_t lhH, cmErr_t* err )
  32. {
  33. _cmFsLinux_t* p = cmLhAllocZ(lhH,_cmFsLinux_t,1);
  34. p->err = err;
  35. p->lhH = lhH;
  36. p->userDir = _cmCreatePathByExpandingTildePath(p,"~");
  37. p->prefDir = p->userDir; // user preferences will be stored invisible files in the home directory
  38. p->rsrcDir = "/usr/share"; // program resources will be stored in /usr/share/app-name
  39. *pp = p;
  40. return kOkFsRC;
  41. }
  42. cmFsRC_t _cmLinuxFileSysFinalize( _cmFsLinux_t* p )
  43. {
  44. return kOkFsRC;
  45. }