Changeset 14 for trunk/src/helpers/dosh2.c
- Timestamp:
- Dec 9, 2000, 8:19:42 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/dosh2.c
r8 r14 30 30 * This file Copyright (C) 1997-2000 Ulrich Mller, 31 31 * Dmitry A. Steklenev. 32 * This file is part of the XWorkplacesource package.33 * XWorkplaceis free software; you can redistribute it and/or modify32 * This file is part of the "XWorkplace helpers" source package. 33 * This is free software; you can redistribute it and/or modify 34 34 * it under the terms of the GNU General Public License as published 35 35 * by the Free Software Foundation, in version 2 as it comes in the … … 46 46 // as unsigned char 47 47 48 #define INCL_DOSMODULEMGR 49 #define INCL_DOSPROCESS 50 #define INCL_DOSSESMGR 51 #define INCL_DOSQUEUES 52 #define INCL_DOSMISC 53 #define INCL_DOSDEVICES 48 54 #define INCL_DOSDEVIOCTL 49 #define INCL_DOS50 55 #define INCL_DOSERRORS 51 // #define INCL_GPI52 56 #include <os2.h> 57 53 58 #include <stdlib.h> 54 59 #include <string.h> … … 68 73 69 74 /* ****************************************************************** 70 * *71 * Miscellaneous *72 * *75 * 76 * Miscellaneous 77 * 73 78 ********************************************************************/ 74 79 … … 109 114 BOOL fFullyQualified) // in: if TRUE, pcszFile must be fully q'fied 110 115 { 116 APIRET arc = NO_ERROR; 111 117 CHAR szPath[CCHMAXPATH+4] = " :"; 112 118 CHAR szComponent[CCHMAXPATH]; … … 120 126 || (*(pcszFile + 2) != '\\') 121 127 ) 122 return (ERROR_CURRENT_DIRECTORY);128 arc = ERROR_CURRENT_DIRECTORY; 123 129 } 124 130 … … 127 133 { 128 134 CHAR cDrive = toupper(*pcszFile); 135 double d; 129 136 // drive specified: 130 137 strcpy(szPath, pcszFile); 131 138 szPath[0] = toupper(*pcszFile); 132 if (doshQueryDiskFree(cDrive - 'A' + 1) == -1) 133 return (ERROR_INVALID_DRIVE); 139 arc = doshQueryDiskFree(cDrive - 'A' + 1, &d); 134 140 } 135 141 else … … 138 144 ULONG ulDriveNum = 0, 139 145 ulDriveMap = 0; 140 DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap);146 arc = DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap); 141 147 szPath[0] = ((UCHAR)ulDriveNum) + 'A' - 1; 142 148 szPath[1] = ':'; … … 144 150 } 145 151 146 fIsFAT = doshIsFileOnFAT(szPath); 147 148 pszInvalid = (fIsFAT) 149 ? "<>|+=:;,\"/[] " // invalid characters in FAT 150 : "<>|:\"/"; // invalid characters in IFS's 151 152 // now separate path components 153 p1 = &szPath[2]; // advance past ':' 154 155 do { 156 157 if (*p1 == '\\') 158 p1++; 159 160 p2 = strchr(p1, '\\'); 161 if (p2 == NULL) 162 p2 = p1 + strlen(p1); 163 164 if (p1 != p2) 165 { 166 LONG lDotOfs = -1, 167 lAfterDot = -1; 168 ULONG cbFile, 169 ul; 170 PSZ pSource = szComponent; 171 172 strncpy(szComponent, p1, p2-p1); 173 szComponent[p2-p1] = 0; 174 cbFile = strlen(szComponent); 175 176 // now check each path component 177 for (ul = 0; ul < cbFile; ul++) 152 if (arc == NO_ERROR) 153 { 154 fIsFAT = doshIsFileOnFAT(szPath); 155 156 pszInvalid = (fIsFAT) 157 ? "<>|+=:;,\"/[] " // invalid characters in FAT 158 : "<>|:\"/"; // invalid characters in IFS's 159 160 // now separate path components 161 p1 = &szPath[2]; // advance past ':' 162 163 do { 164 165 if (*p1 == '\\') 166 p1++; 167 168 p2 = strchr(p1, '\\'); 169 if (p2 == NULL) 170 p2 = p1 + strlen(p1); 171 172 if (p1 != p2) 178 173 { 174 LONG lDotOfs = -1, 175 lAfterDot = -1; 176 ULONG cbFile, 177 ul; 178 PSZ pSource = szComponent; 179 180 strncpy(szComponent, p1, p2-p1); 181 szComponent[p2-p1] = 0; 182 cbFile = strlen(szComponent); 183 184 // now check each path component 185 for (ul = 0; ul < cbFile; ul++) 186 { 187 if (fIsFAT) 188 { 189 // on FAT: only 8 characters allowed before dot 190 if (*pSource == '.') 191 { 192 lDotOfs = ul; 193 lAfterDot = 0; 194 if (ul > 7) 195 return (ERROR_FILENAME_EXCED_RANGE); 196 } 197 } 198 // and check for invalid characters 199 if (strchr(pszInvalid, *pSource) != NULL) 200 return (ERROR_INVALID_NAME); 201 202 pSource++; 203 204 // on FAT, allow only three chars after dot 205 if (fIsFAT) 206 if (lAfterDot != -1) 207 { 208 lAfterDot++; 209 if (lAfterDot > 3) 210 return (ERROR_FILENAME_EXCED_RANGE); 211 } 212 } 213 214 // we are still missing the case of a FAT file 215 // name without extension; if so, check whether 216 // the file stem is <= 8 chars 179 217 if (fIsFAT) 180 { 181 // on FAT: only 8 characters allowed before dot 182 if (*pSource == '.') 183 { 184 lDotOfs = ul; 185 lAfterDot = 0; 186 if (ul > 7) 218 if (lDotOfs == -1) // dot not found: 219 if (cbFile > 8) 187 220 return (ERROR_FILENAME_EXCED_RANGE); 188 }189 }190 // and check for invalid characters191 if (strchr(pszInvalid, *pSource) != NULL)192 return (ERROR_INVALID_NAME);193 194 pSource++;195 196 // on FAT, allow only three chars after dot197 if (fIsFAT)198 if (lAfterDot != -1)199 {200 lAfterDot++;201 if (lAfterDot > 3)202 return(ERROR_FILENAME_EXCED_RANGE);203 }204 221 } 205 222 206 // we are still missing the case of a FAT file 207 // name without extension; if so, check whether 208 // the file stem is <= 8 chars 209 if (fIsFAT) 210 if (lDotOfs == -1) // dot not found: 211 if (cbFile > 8) 212 return (ERROR_FILENAME_EXCED_RANGE); 213 } 214 215 // go for next component 216 p1 = p2+1; 217 } while (*p2); 218 219 return (NO_ERROR); 223 // go for next component 224 p1 = p2+1; 225 } while (*p2); 226 } 227 228 return (arc); 220 229 } 221 230 … … 340 349 341 350 /* ****************************************************************** 342 * *343 * Environment helpers *344 * *351 * 352 * Environment helpers 353 * 345 354 ********************************************************************/ 346 355 … … 716 725 717 726 /* ****************************************************************** 718 * *719 * Module handling helpers *720 * *727 * 728 * Module handling helpers 729 * 721 730 ********************************************************************/ 722 731 … … 773 782 774 783 /******************************************************************** 775 * *776 * Executable functions *777 * *784 * 785 * Executable functions 786 * 778 787 ********************************************************************/ 779 788 … … 1219 1228 1220 1229 /******************************************************************** 1221 * *1222 * Partition functions *1223 * *1230 * 1231 * Partition functions 1232 * 1224 1233 ********************************************************************/ 1225 1234
Note:
See TracChangeset
for help on using the changeset viewer.