You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "IM_DataStructs.h"
  2. CSTR buildMd5Path( CSTR base, CSTR md5, mode_t mode, CSTR user, CSTR group ){
  3. char tPath[1024];
  4. char p1[3];
  5. char p2[3];
  6. char p3[3];
  7. if(!fileExist( base )) return NULL;
  8. memcpy( p1, md5 , 2); p1[2]=(char)0;
  9. sprintf( tPath, "%s/%s", base, p1 );
  10. if(!fileExist( tPath )) {
  11. if( mkdir( tPath, mode )==-1) return NULL;
  12. if( user!= NULL && group!= NULL ) ch_chown( tPath, user, group );
  13. };
  14. memcpy( p2, md5+2, 2); p2[2]=(char)0;
  15. sprintf( tPath, "%s/%s/%s", base, p1, p2 );
  16. if(!fileExist( tPath )){
  17. if( mkdir( tPath, mode )==-1) return NULL;
  18. if( user!= NULL && group!= NULL ) ch_chown( tPath, user, group );
  19. };
  20. memcpy( p3, md5+4, 2); p3[2]=(char)0;
  21. sprintf( tPath, "%s/%s/%s/%s", base, p1, p2, p3 );
  22. if(!fileExist( tPath )) {
  23. if( mkdir( tPath, mode )==-1) return NULL;
  24. if( user!= NULL && group!= NULL ) ch_chown( tPath, user, group );
  25. };
  26. return strdup( tPath );
  27. };