|
|
1.1.1.9 root 1: /* 1.1.1.11! root 2: Legal Notice: Some portions of the source code contained in this file were ! 3: derived from the source code of Encryption for the Masses 2.02a, which is ! 4: Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License ! 5: Agreement for Encryption for the Masses'. Modifications and additions to ! 6: the original source code (contained in this file) and all other portions of ! 7: this file are Copyright (c) 2003-2008 TrueCrypt Foundation and are governed ! 8: by the TrueCrypt License 2.4 the full text of which is contained in the ! 9: file License.txt included in TrueCrypt binary and source code distribution 1.1.1.9 root 10: packages. */ 1.1 root 11: 1.1.1.6 root 12: #include "Tcdefs.h" 1.1 root 13: 1.1.1.6 root 14: #include <sys/types.h> 15: #include <sys/stat.h> 1.1 root 16: #include <direct.h> 17: #include <string.h> 18: #include <stdlib.h> 19: #include <errno.h> 20: 1.1.1.6 root 21: #include "Dir.h" 1.1 root 22: 23: /* create full directory tree. returns 0 for success, -1 if failure */ 24: int 1.1.1.11! root 25: mkfulldir (char *oriPath, BOOL bCheckonly) 1.1 root 26: { 27: struct _stat st; 28: char *uniq_file; 1.1.1.11! root 29: char path [TC_MAX_PATH]; ! 30: ! 31: strcpy (path, oriPath); 1.1 root 32: 33: if (strlen (path) == 3 && path[1] == ':') 34: goto is_root; /* keep final slash in root if present */ 35: 36: /* strip final forward or backslash if we have one! */ 37: uniq_file = strrchr (path, '\\'); 38: if (uniq_file && uniq_file[1] == '\0') 39: uniq_file[0] = '\0'; 40: else 41: { 42: uniq_file = strrchr (path, '/'); 43: if (uniq_file && uniq_file[1] == '\0') 44: uniq_file[0] = '\0'; 45: } 46: 47: is_root: 1.1.1.6 root 48: if (bCheckonly) 1.1 root 49: return _stat (path, &st); 50: 51: if (_stat (path, &st)) 52: return mkfulldir_internal (path); 53: else 54: return 0; 55: } 56: 57: 58: int 59: mkfulldir_internal (char *path) 60: { 61: char *token; 62: struct _stat st; 63: static char tokpath[_MAX_PATH]; 64: static char trail[_MAX_PATH]; 65: 66: strcpy (tokpath, path); 67: trail[0] = '\0'; 68: 69: token = strtok (tokpath, "\\/"); 70: 71: if (tokpath[0] == '\\' && tokpath[1] == '\\') 72: { /* unc */ 73: trail[0] = tokpath[0]; 74: trail[1] = tokpath[1]; 75: trail[2] = '\0'; 76: strcat (trail, token); 77: strcat (trail, "\\"); 78: token = strtok (NULL, "\\/"); 79: if (token) 80: { /* get share name */ 81: strcat (trail, token); 82: strcat (trail, "\\"); 83: } 84: token = strtok (NULL, "\\/"); 85: } 86: 87: if (tokpath[1] == ':') 88: { /* drive letter */ 89: strcat (trail, tokpath); 90: strcat (trail, "\\"); 91: token = strtok (NULL, "\\/"); 92: } 93: 94: while (token != NULL) 95: { 96: int x; 97: strcat (trail, token); 98: x = _mkdir (trail); 99: strcat (trail, "\\"); 100: token = strtok (NULL, "\\/"); 101: } 102: 103: return _stat (path, &st); 104: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.