Mercurial > dwindows
comparison win/dirent.c @ 260:e320dc29bfcd
Rewrote abs_path() so the code will work on NT 4.0.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 23 Feb 2003 06:35:18 +0000 |
parents | 4ec906d40ce2 |
children | e0ea29c3d1eb |
comparison
equal
deleted
inserted
replaced
259:22a215209887 | 260:e320dc29bfcd |
---|---|
54 r = GetDriveType(drive); | 54 r = GetDriveType(drive); |
55 | 55 |
56 return cache [unit] = r; | 56 return cache [unit] = r; |
57 } | 57 } |
58 | 58 |
59 char * | 59 char *abs_path(const char *name, char *buffer, int len) |
60 abs_path(const char *name, char *buffer, int len) | 60 { |
61 { | 61 char *buf; |
62 char buf[4]; | 62 LPTSTR file; |
63 if (isalpha(name[0]) && name[1] == ':' && name[2] == '\0') { | 63 |
64 buf[0] = name[0]; | 64 if(isalpha(name[0]) && name[1] == ':' && name[2] == '\0') |
65 buf[1] = name[1]; | 65 { |
66 buf[2] = '.'; | 66 int drive = _getdrive(); |
67 buf[3] = '\0'; | 67 char newdrive = toupper(name[0]); |
68 name = buf; | 68 |
69 } | 69 _chdrive((newdrive - 'A')+1); |
70 if (GetLongPathName(name, buffer, len)) | 70 |
71 if(getcwd(buffer, len)) | |
72 { | |
73 _chdrive(drive); | |
74 return buffer; | |
75 } | |
76 _chdrive(drive); | |
71 return NULL; | 77 return NULL; |
72 return buffer; | 78 } |
73 } | 79 if(GetFullPathName(name, len, buffer, &file)) |
74 | 80 return buffer; |
75 DIR * | 81 return NULL; |
76 openxdir(const char *path, unsigned att_mask) | 82 } |
83 | |
84 DIR *openxdir(const char *path, unsigned att_mask) | |
77 { | 85 { |
78 DIR *dir; | 86 DIR *dir; |
79 char name[MAXPATHLEN+3]; | 87 char name[MAXPATHLEN+3]; |
80 | 88 |
81 dir = malloc(sizeof(DIR)); | 89 dir = malloc(sizeof(DIR)); |