Changeset 54
- Timestamp:
- 06/29/09 09:20:29 (3 years ago)
- Files:
-
- trunk/Source/build.d (modified) (12 diffs)
- trunk/Source/build_bn.d (modified) (1 diff)
- trunk/Source/opts.d (modified) (2 diffs)
- trunk/Source/opts_bn.d (modified) (1 diff)
- trunk/Source/source.d (modified) (22 diffs)
- trunk/Source/source_bn.d (modified) (1 diff)
- trunk/Source/util/booltype.d (modified) (5 diffs)
- trunk/Source/util/fdt.d (modified) (9 diffs)
- trunk/Source/util/file2.d (modified) (4 diffs)
- trunk/Source/util/file2_bn.d (modified) (1 diff)
- trunk/Source/util/fileex.d (modified) (6 diffs)
- trunk/Source/util/fileex_bn.d (modified) (1 diff)
- trunk/Source/util/linetoken.d (modified) (2 diffs)
- trunk/Source/util/linetoken_bn.d (modified) (1 diff)
- trunk/Source/util/macroex.d (modified) (2 diffs)
- trunk/Source/util/pathex.d (modified) (10 diffs)
- trunk/Source/util/pathex_bn.d (modified) (1 diff)
- trunk/Source/util/str.d (modified) (8 diffs)
- trunk/Source/util/str_bn.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Source/build.d
r53 r54 32 32 alias char[] text; 33 33 34 version(D_Version2) 35 { 36 mixin("alias invariant(dchar) dcharc;"); 37 mixin("alias invariant(wchar) wcharc;"); 38 mixin("alias invariant(char) charc;"); 39 } 40 else 41 { 34 const vMyVersion = "3.05"; 42 35 alias char[] string; 43 36 alias wchar[] wstring; … … 46 39 alias dchar dcharc; 47 40 alias char charc; 48 }49 50 41 51 42 version(unix) version = Unix; … … 54 45 version(darwin) version = Posix; 55 46 56 const vMyVersion = "3.05";57 47 version(build) pragma(todo, "Single file compilation"); 58 48 version(build) pragma(todo, "Output Paths"); … … 364 354 delegate int (inout int i, inout source.Source lSource) 365 355 { 356 string lParent; 357 string lRoot; 358 359 lParent = util.pathex.ParentPath(lSource.FileName); 360 lRoot = AddRoot( lParent ); 361 version(BuildVerbose) 362 { 363 if(lRoot.length > 0 && opts.Verbose == True) 364 { 365 std.stdio.writefln("%s: Extra root added %s", opts.MyName, lRoot); 366 } 367 } 368 366 369 // Get the next Source object to examine. 367 370 if (lSource.Ignore) … … 1671 1674 { 1672 1675 // Scan all paths for config file but couldn't find one. 1673 throw new BuildException( std.string.format(" Unable to find Config File '%s' in \n%s",1674 opts. ConfigFile, lPotentialPaths));1676 throw new BuildException( std.string.format("%s: Unable to find Config File '%s' in \n%s", 1677 opts.MyName, opts.ConfigFile, lPotentialPaths)); 1675 1678 } 1676 1679 } … … 1906 1909 string[] lFileExtList; 1907 1910 1908 lFileExtList ~= std. file.getExt(pFileName);1911 lFileExtList ~= std.path.getExt(pFileName); 1909 1912 if (lFileExtList[0] == opts.SrcExtension) 1910 1913 { … … 2110 2113 } 2111 2114 2115 // Preload import roots from the current directory. 2116 { 2117 string lCurDir = util.pathex.GetInitCurDir; 2118 string lRoot; 2119 lRoot = AddRoot(lCurDir); 2120 version(BuildVerbose) 2121 { 2122 if(opts.Verbose == True && lRoot.length > 0) 2123 std.stdio.writefln("%s: Added root from current directory = %s", opts.MyName, lRoot); 2124 } 2125 2126 string[] lSubDirs = util.pathex.SubDirs(lCurDir); 2127 foreach(string lSubDir; lSubDirs) 2128 { 2129 lRoot = AddRoot(lSubDir); 2130 version(BuildVerbose) 2131 { 2132 if(opts.Verbose == True && lRoot.length > 0) 2133 std.stdio.writefln("%s: Added root from current directory = %s", opts.MyName, lRoot); 2134 } 2135 } 2136 2137 string lParent = util.pathex.ParentPath(lCurDir); 2138 lRoot = AddRoot(lParent); 2139 version(BuildVerbose) 2140 { 2141 if(opts.Verbose == True && lRoot.length > 0) 2142 std.stdio.writefln("%s: Added root from current directory = %s", opts.MyName, lRoot); 2143 } 2144 } 2145 2112 2146 GatherArgs( pArgs ); 2113 2147 … … 2126 2160 2127 2161 if( (vTargetName.length == 0) && (vCommandTargetName.length == 0) ){ 2128 throw new BuildException( "No target name supplied.");2162 throw new BuildException(opts.MyName ~ ": No target name supplied."); 2129 2163 } 2130 2164 … … 2162 2196 if (util.file2.FileExists(opts.CompilerPath ~ opts.CompilerExe) == false) 2163 2197 { 2164 throw new BuildException(std.string.format(" The compiler '%s' was not found.",2165 opts. CompilerPath ~ opts.CompilerExe));2198 throw new BuildException(std.string.format("%s: The compiler '%s' was not found.", 2199 opts.MyName, opts.CompilerPath ~ opts.CompilerExe)); 2166 2200 } 2167 2201 … … 2205 2239 if ( lAllExist == false) 2206 2240 { 2207 throw new BuildException ( "Not all supplied files exist.");2241 throw new BuildException (opts.MyName ~ ": Not all supplied files exist."); 2208 2242 } 2209 2243 … … 2991 3025 { 2992 3026 if (vEmptyArgs == False) 2993 throw new BuildException( "Empty arguments are not allowed");3027 throw new BuildException(opts.MyName ~ ": Empty arguments are not allowed"); 2994 3028 else 2995 3029 return; … … 3454 3488 if (lCmdCount == 0) 3455 3489 { 3456 throw new BuildException( "No configuration file items found.");3457 } 3458 } 3490 throw new BuildException(opts.MyName ~ ": No configuration file items found."); 3491 } 3492 } trunk/Source/build_bn.d
r53 r54 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 3 230;4 long auto_build_number = 3379; trunk/Source/opts.d
r53 r54 29 29 module opts; 30 30 private import opts_bn; // This module's build number 31 version(D_Version2)32 {33 mixin("alias const(dchar) dcharc;");34 mixin("alias const(wchar) wcharc;");35 mixin("alias const(char) charc;");36 }37 else38 {39 31 alias char[] string; 40 32 alias wchar[] wstring; … … 43 35 alias dchar dcharc; 44 36 alias char charc; 45 }46 37 47 38 trunk/Source/opts_bn.d
r53 r54 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 511;4 long auto_build_number = 640; trunk/Source/source.d
r53 r54 39 39 module source; 40 40 private import source_bn; // Build number for this module 41 version(D_Version2)42 {43 mixin("alias const(wchar)[] wstring;");44 mixin("alias const(dchar)[] dstring;");45 mixin("alias const(dchar) dcharc;");46 mixin("alias const(wchar) wcharc;");47 mixin("alias const(char) charc;");48 }49 else50 {51 41 alias char[] string; 52 42 alias wchar[] wstring; … … 55 45 alias dchar dcharc; 56 46 alias char charc; 57 }58 47 59 48 … … 84 73 static import std.file; 85 74 static import std.string; 75 import std.conv; 86 76 } 87 77 … … 320 310 // -------------------------------------------------------------------- 321 311 { 322 if (pFileName in Source.smSourceIndex) 312 // Find the file. 313 string lFile = ExpandPathName(pFileName, False); 314 string lStdName; 315 version(Windows) 316 { 317 lStdName = std.string.tolower(lFile); 318 } 319 else 320 { 321 lStdName = lFile; 322 } 323 324 if (lStdName in Source.smSourceIndex) 323 325 { 324 326 if (pMode == Source.EMode.Update) 325 327 { 326 Source.smSourceIndex[ pFileName].create("");328 Source.smSourceIndex[lStdName].create(""); 327 329 } 328 330 else … … 336 338 else 337 339 { 338 create(pFileName); 340 if (util.file2.FileExists(lFile) == false) 341 { 342 if (util.pathex.IsAbsolutePath(pFileName) == True) 343 { 344 throw new SourceException(opts.MyName ~ ": File '" ~ pFileName ~ "' was not found at that location."); 345 //return; 346 } 347 348 lStdName = util.pathex.LocateFile(pFileName, GetImportRoots()); 349 if (lStdName.ptr == pFileName.ptr) // Full name not found. 350 { 351 lStdName = null; 352 353 L_ScanSubDirs: 354 foreach(string lPotentialDir; GetImportRoots()) 355 { 356 string[] lSubDirs = util.pathex.SubDirs(lPotentialDir); 357 foreach(string lSubDir; lSubDirs) 358 { 359 360 if (util.file2.FileExists(lSubDir ~ std.path.sep ~ pFileName) == true) 361 { 362 string lRoot = AddRoot(lSubDir); 363 version(BuildVerbose) 364 { 365 if(opts.Verbose == True && lRoot.length > 0) 366 std.stdio.writefln("%s: Added root from sub directory = %s", opts.MyName, lRoot); 367 } 368 lStdName = lSubDir ~ std.path.sep ~ pFileName; 369 break L_ScanSubDirs; 370 } 371 } 372 373 string lParent = util.pathex.ParentPath(lPotentialDir); 374 if (util.file2.FileExists(lParent ~ std.path.sep ~ pFileName) == true) 375 { 376 string lRoot = AddRoot(lParent); 377 version(BuildVerbose) 378 { 379 if(opts.Verbose == True && lRoot.length > 0) 380 std.stdio.writefln("%s: Added root from parent directory = %s", opts.MyName, lRoot); 381 } 382 lStdName = lParent ~ std.path.sep ~ pFileName; 383 break L_ScanSubDirs; 384 } 385 } 386 } 387 388 389 if (lStdName.length == 0) 390 { 391 throw new SourceException(opts.MyName ~ ": File scan did not find '" ~ pFileName ~ "'."); 392 } 393 394 lFile = lStdName; 395 mFileName = lStdName; 396 } 397 create(lFile); 339 398 } 340 399 } … … 346 405 string lObjectName; 347 406 407 string lStdName; 408 version(Windows) 409 { 410 lStdName = std.string.tolower(pFileName); 411 } 412 else 413 { 414 lStdName = pFileName; 415 } 416 348 417 mReferencedImports.length = 0; 349 418 mHasBeenSearched = false; … … 353 422 mFileName = pFileName; 354 423 // Store this instantiation in the list of known files. 355 smSourceIndex[ pFileName] = this;424 smSourceIndex[lStdName] = this; 356 425 } 357 426 else … … 445 514 if (util.file2.FileExists(mFileName) == false) 446 515 { 447 throw new SourceException( "File '" ~ mFileName ~ "' does not exist.");516 throw new SourceException(opts.MyName ~ ": File '" ~ mFileName ~ "' was not found."); 448 517 //return; 449 518 } … … 457 526 if (mHasBeenSearched == false) 458 527 { 459 smScanOrder.length = smScanOrder.length + 1; 460 smScanOrder[$-1] = mFileName; 528 version(Windows) 529 { 530 smScanOrder ~= std.string.tolower(mFileName); 531 } 532 else 533 { 534 smScanOrder ~= mFileName; 535 } 461 536 } 462 537 … … 1246 1321 if ((lCurrentToken != ",") && (lCurrentToken != kCloseParen)) 1247 1322 { 1248 lPragmaId ~= lCurrentToken ;1323 lPragmaId ~= lCurrentToken.dup; 1249 1324 } 1250 1325 else … … 1282 1357 if (AddBuildDef != null) 1283 1358 { 1284 AddBuildDef(lCurrentToken. idup);1359 AddBuildDef(lCurrentToken.dup); 1285 1360 } 1286 1361 } … … 1366 1441 } 1367 1442 if (AddTarget != null) 1368 AddTarget(lCurrentToken.idup);1443 AddTarget(lCurrentToken.dup); 1369 1444 } 1370 1445 … … 1407 1482 } 1408 1483 else 1409 lExternOpts[$-1] = lCurrentToken.idup; 1484 lExternOpts[$-1] = lCurrentToken.dup; 1485 1410 1486 1411 1487 lCurrentToken = GetNextToken(pFileText,pPos); … … 1449 1525 if (std.string.tolower(std.path.getExt(lCurrentToken)) == "ddoc") 1450 1526 { 1451 mReferencedImports ~= lCurrentToken. idup;1527 mReferencedImports ~= lCurrentToken.dup; 1452 1528 } 1453 1529 else … … 1521 1597 lCurrentToken = `"` ~ GetStringLit(pFileText,pPos, lCurrentToken[0]) ~ `"`; 1522 1598 } 1523 mLocalArgs ~= lCurrentToken. idup;1599 mLocalArgs ~= lCurrentToken.dup; 1524 1600 } 1525 1601 … … 1630 1706 } 1631 1707 1632 if (pPos > lLastPos) { throw new SourceException( "Mismatched nested comments in " ~ mFileName); }1708 if (pPos > lLastPos) { throw new SourceException(opts.MyName ~ ": Mismatched nested comments in " ~ mFileName); } 1633 1709 } 1634 1710 } // else … … 1884 1960 if (lRuleIdx + 1 == lRules.length) 1885 1961 throw new SourceException( 1886 std.string.format("%s: Cannot find rule '%s'",1887 pScanningFile, pRef.Rule));1962 std.string.format("%s: %s: Cannot find rule '%s'", 1963 opts.MyName, pScanningFile, pRef.Rule)); 1888 1964 continue; 1889 1965 } … … 1896 1972 if ( (lExtension != r.Input) && (lExtension != r.Output)) 1897 1973 throw new SourceException( 1898 std.string.format("%s: Using rule '%s' for file '%s'"1974 std.string.format("%s: %s: Using rule '%s' for file '%s'" 1899 1975 " but no matching file type in rule.", 1900 pScanningFile, pRef.Rule, pRef.FilePath));1976 opts.MyName, pScanningFile, pRef.Rule, pRef.FilePath)); 1901 1977 } 1902 1978 … … 1918 1994 if (! util.file2.FileExists( lInFile ) ) 1919 1995 throw new SourceException( 1920 std.string.format(" External input file '%s' not found", lInFile));1996 std.string.format("%s: External input file '%s' not found", opts.MyName, lInFile)); 1921 1997 1922 1998 string lTemp; … … 1997 2073 { 1998 2074 if (Source[lInFile] is null) 2075 { 1999 2076 new Source(lInFile); 2077 } 2000 2078 } 2001 2079 else if (r.InUse == eRuleUsage.Link) … … 2069 2147 { 2070 2148 throw new SourceException( 2071 std.string.format(" Rule '%s' does not specify a tool to use.",2072 lRules[$-1].Name));2149 std.string.format("%s: Rule '%s' does not specify a tool to use.", 2150 opts.MyName, lRules[$-1].Name)); 2073 2151 } 2074 2152 } … … 2165 2243 if (lRunResult != 0) 2166 2244 // If an external tool fails, stop immediately. 2167 throw new SourceException(std.string.format("External Tool for %s failed with code %s", pPath, lRunResult)); 2245 throw new SourceException(std.string.format("%s: External Tool for %s failed with code %s", 2246 opts.MyName, pPath, lRunResult)); 2168 2247 } 2169 2248 trunk/Source/source_bn.d
r53 r54 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 2933;4 long auto_build_number = 3076; trunk/Source/util/booltype.d
r52 r54 50 50 module util.booltype; 51 51 version(build) version(BoolUnknown) pragma(include, booltypemac.ddoc); 52 version(D_Version2)53 {54 mixin("alias invariant(dchar) dcharc;");55 mixin("alias invariant(wchar) wcharc;");56 mixin("alias invariant(char) charc;");57 }58 else59 {60 52 alias char[] string; 61 53 alias wchar[] wstring; … … 64 56 alias dchar dcharc; 65 57 alias char charc; 66 }67 58 68 59 … … 77 68 class Bool 78 69 { 70 //alias super.opCmp opCmp; 71 //alias super.opEquals opEquals; 79 72 int m_Val; 80 73 … … 186 179 * -------------------- 187 180 **/ 181 alias Object.opEquals opEquals; 182 188 183 int opEquals(Bool pOther) { 189 184 version(BoolUnknown) … … 214 209 * -------------------- 215 210 **/ 211 alias Object.opCmp opCmp; 216 212 int opCmp(Bool pOther) { 217 213 version(BoolUnknown) trunk/Source/util/fdt.d
r52 r54 54 54 version(linux) version = Posix; 55 55 version(darwin) version = Posix; 56 version(D_Version2)57 {58 mixin("alias invariant(dchar) dcharc;");59 mixin("alias invariant(wchar) wcharc;");60 mixin("alias invariant(char) charc;");61 }62 else63 {64 56 alias char[] string; 65 57 alias wchar[] wstring; … … 68 60 alias dchar dcharc; 69 61 alias char charc; 70 }71 62 72 63 … … 194 185 * -------------------- 195 186 **/ 187 alias Object.opEquals opEquals; 196 188 int opEquals(FileDateTime pOther) { return Compare(pOther) == 0; } 197 189 … … 213 205 * -------------------- 214 206 **/ 207 alias Object.opCmp opCmp; 215 208 int opCmp(FileDateTime pOther) { return Compare(pOther); } 216 209 … … 329 322 * -------------------- 330 323 **/ 324 331 325 string toString(bool pExact = false) 332 326 { … … 432 426 } 433 427 434 this( char[]pFileName)428 this(string pFileName) 435 429 { 436 430 GetFileTime( pFileName ); … … 442 436 } 443 437 444 this(d char[]pFileName)438 this(dstring pFileName) 445 439 { 446 440 GetFileTime( std.utf.toUTF8(pFileName) ); … … 461 455 return 0; 462 456 } 463 464 char[]toString()457 458 string toString() 465 459 { 466 460 if ( mSet == False ) … … 472 466 473 467 474 private void GetFileTime( char[]pFileName)468 private void GetFileTime(string pFileName) 475 469 { 476 470 trunk/Source/util/file2.d
r52 r54 39 39 module util.file2; 40 40 private import util.file2_bn; // The build number for this module. 41 version(D_Version2)42 {43 mixin("alias const(wchar)[] wstring;");44 mixin("alias const(dchar)[] dstring;");45 mixin("alias const(dchar) dcharc;");46 mixin("alias const(wchar) wcharc;");47 mixin("alias const(char) charc;");48 }49 else50 {51 41 alias char[] string; 52 42 alias wchar[] wstring; … … 55 45 alias dchar dcharc; 56 46 alias char charc; 57 }58 47 59 48 … … 84 73 return true; 85 74 } 86 try {87 if(std.file.isfile(pFileName) && std.file.exists(pFileName))75 76 try 88 77 { 89 lExistingFiles[pFileName] = true; 90 return true; 91 } 78 if(std.file.isfile(pFileName) && std.file.exists(pFileName)) 79 { 80 lExistingFiles[pFileName] = true; 81 return true; 82 } 92 83 } catch { }; 93 84 return false; … … 97 88 void PurgeFileExistsCache() 98 89 { 99 string[] lKeys; 100 101 lKeys = lExistingFiles.keys.dup; 102 foreach(string lFile; lKeys) 103 { 104 lExistingFiles.remove(lFile); 105 } 90 lExistingFiles = null; 106 91 } 107 92 trunk/Source/util/file2_bn.d
r53 r54 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 936;4 long auto_build_number = 1063; trunk/Source/util/fileex.d
r52 r54 44 44 version(linux) version = Posix; 45 45 version(darwin) version = Posix; 46 version(D_Version2)47 {48 mixin("alias invariant(dchar) dcharc;");49 mixin("alias invariant(wchar) wcharc;");50 mixin("alias invariant(char) charc;");51 }52 else53 {54 46 alias char[] string; 55 47 alias wchar[] wstring; … … 58 50 alias dchar dcharc; 59 51 alias char charc; 60 }61 52 62 53 alias char[] text; … … 206 197 int grep(string pData, string pPattern) 207 198 { 208 return std.regexp.find(pData .idup, pPattern.idup, vGrepOpts[$-1].idup);199 return std.regexp.find(pData, pPattern, vGrepOpts[$-1]); 209 200 } 210 201 … … 367 358 return RunCommand( util.str.enquote(pExeName) ~ " " ~ pCommand, pCallBack); 368 359 } 360 361 import std.c.string; 362 //------------------------------------------------------- 363 string copystrz(char* s) 364 //------------------------------------------------------- 365 { 366 string ts; 367 char* tsp; 368 369 ts.length = std.c.string.strlen(s) + 1; 370 tsp = ts.ptr; 371 while(*s) 372 *tsp++ = *s++; 373 *tsp = '\0'; 374 return ts; 375 } 376 369 377 //------------------------------------------------------- 370 378 int RunCommand(string pCommand, runCallBack pCallBack = null) … … 372 380 { 373 381 int lRC; 374 int lTrueRC;375 382 376 383 if (pCallBack !is null) … … 380 387 return 0; 381 388 } 382 383 384 lRC = system(std.string.toStringz(pCommand)); 385 version(Posix) lTrueRC = ((lRC & 0xFF00) >> 8); 386 version(Windows) lTrueRC = lRC; 387 388 pCallBack(2, pCommand, lTrueRC); 389 return lTrueRC; 390 391 } 392 389 string TempStr; 390 391 TempStr = copystrz(std.string.toStringz(pCommand)); 392 393 lRC = system(TempStr.ptr); 394 version(Posix) lRC = ((lRC & 0xFF00) >> 8); 395 396 if (pCallBack !is null) 397 pCallBack(2, pCommand, lRC); 398 return lRC; 399 } 400 trunk/Source/util/fileex_bn.d
r53 r54 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 2 736;4 long auto_build_number = 2876; trunk/Source/util/linetoken.d
r52 r54 38 38 module util.linetoken; 39 39 private import util.linetoken_bn; 40 version(D_Version2)41 {42 mixin("alias const(dchar) dcharc;");43 mixin("alias const(wchar) wcharc;");44 mixin("alias const(char) charc;");45 }46 else47 {48 40 alias char[] string; 49 41 alias wchar[] wstring; … … 52 44 alias dchar dcharc; 53 45 alias char charc; 54 }55 46 56 47 trunk/Source/util/linetoken_bn.d
r53 r54 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 2 883;4 long auto_build_number = 2997; trunk/Source/util/macroex.d
r52 r54 37 37 **************************************************************************/ 38 38 module util.macroex; 39 version(D_Version2)40 {41 mixin("alias invariant(dchar) dcharc;");42 mixin("alias invariant(wchar) wcharc;");43 mixin("alias invariant(char) charc;");44 }45 else46 {47 39 alias char[] string; 48 40 alias wchar[] wstring; … … 51 43 alias dchar dcharc; 52 44 alias char charc; 53 }54 45 55 46 trunk/Source/util/pathex.d
r52 r54 39 39 module util.pathex; 40 40 private import util.pathex_bn; // The build number for this module. 41 version(D_Version2)42 {43 mixin("alias invariant(dchar) dcharc;");44 mixin("alias invariant(wchar) wcharc;");45 mixin("alias invariant(char) charc;");46 }47 else48 {49 41 alias char[] string; 50 42 alias wchar[] wstring; … … 53 45 alias dchar dcharc; 54 46 alias char charc; 55 }56 47 57 48 … … 119 110 string lOrigDir; 120 111 string lCurDir; 121 textlDrive;112 string lDrive; 122 113 123 114 lOrigDir = std.file.getcwd(); 124 lDrive.length = 2; 125 lDrive[0] = pDrive; 126 lDrive[1] = ':'; 127 std.file.chdir(lDrive.idup); 115 lDrive = pDrive ~ ":"; 116 std.file.chdir(lDrive); 128 117 lCurDir = std.file.getcwd(); 129 118 std.file.chdir(lOrigDir[0..2]); … … 283 272 if (lRetLen != 0) 284 273 { 285 lPath = lShortPath[0..lRetLen].idup ~ lFileNamePart;274 lPath = (lShortPath[0..lRetLen] ~ lFileNamePart).dup; 286 275 } 287 276 } … … 428 417 429 418 // ---------------------------------------------- 419 string ParentPath(string pPath) 420 // ---------------------------------------------- 421 { 422 // Strip off any terminal path separator. 423 if (pPath.length > 0 && pPath[$-1] == std.path.sep[0]) 424 { 425 pPath.length = pPath.length - 1; 426 } 427 428 string lFullName = CanonicalPath(pPath, False, False); 429 430 // extract out the parent directory 431 for (int i = lFullName.length-1; i >= 0; i--) 432 { 433 if (lFullName[i] == std.path.sep[0]) 434 return lFullName[0 .. i]; 435 } 436 return ""; // Should never get here. 437 438 } 439 440 441 // ---------------------------------------------- 430 442 Bool MakePath(string pNewPath) 431 443 // ---------------------------------------------- … … 460 472 } 461 473 } 462 version(Windows) { 474 version(Windows) 475 { 476 // Strip off any drive specified. 463 477 if ((lNewPath.length > 0) && (lNewPath[length-1] == ':')) 464 478 lNewPath.length = 0; … … 467 481 if (lNewPath.length == 0) 468 482 return False; 469 else {483 470 484 // extract out the parent directory 471 485 for (int i = lNewPath.length-1; i >= 0; i--) … … 479 493 480 494 // make sure the parent exists. 481 version(Windows) { 495 version(Windows) 496 { 482 497 if ((lParentPath.length > 0) && (lParentPath[length-1] == ':')) 483 498 lParentPath.length = 0; 484 499 } 500 485 501 if (lParentPath.length != 0) 486 502 { … … 490 506 491 507 // create this directory 492 try { 508 try 509 { 493 510 std.file.mkdir(lNewPath); 494 511 lResult = True; 495 512 } 496 catch (std.file.FileException E) { 513 catch 514 { 497 515 // Assume the exception is that the directory already exists. 498 516 lResult = False; 499 517 } 500 518 return lResult; 501 } 519 502 520 } 503 521 … … 763 781 } 764 782 783 // Get a list of subdirectories contained in the path. 784 // Only one level deep is checked. 785 // Path can be either a directory or file. 786 787 string[] SubDirs( string pPath, int pIsDir = -1) 788 { 789 string lPath; 790 string[] lList; 791 int lIsDir; 792 793 794 lIsDir = pIsDir; 795 try 796 { 797 lIsDir = std.file.isdir(pPath); 798 } 799 catch { /* ignore exception, assume its meant to be a path name. */ } 800 801 if (lIsDir == 0) 802 { 803 lPath = std.path.getDirName(pPath); 804 if (lPath.length == 0) 805 { 806 lPath = "."; 807 } 808 } 809 else 810 lPath = pPath; 811 812 bool ldcb(std.file.DirEntry* de) 813 { 814 if (de.isdir) 815 { 816 lList ~= de.name; 817 } 818 return true; 819 } 820 821 std.file.listdir(lPath, &ldcb); 822 823 return lList; 824 } trunk/Source/util/pathex_bn.d
r53 r54 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 2 760;4 long auto_build_number = 2919; trunk/Source/util/str.d
r52 r54 42 42 module util.str; 43 43 private import util.str_bn; 44 version(D_Version2)45 {46 mixin("alias invariant(dchar) dcharc;");47 mixin("alias invariant(wchar) wcharc;");48 mixin("alias invariant(char) charc;");49 }50 else51 {52 44 alias char[] string; 53 45 alias wchar[] wstring; … … 56 48 alias dchar dcharc; 57 49 alias char charc; 58 }59 50 60 51 alias dchar[] dtext; … … 210 201 } 211 202 212 return lTemp. idup;203 return lTemp.dup; 213 204 } 214 205 … … 891 882 892 883 lUTF8[0] = pChar; 893 return lUTF8[0..1]. idup;884 return lUTF8[0..1].dup; 894 885 } 895 886 … … 1180 1171 } 1181 1172 1182 return (lChanged ? lResult. idup : pUTF8);1173 return (lChanged ? lResult.dup : pUTF8); 1183 1174 } 1184 1175 … … 1450 1441 } 1451 1442 1452 return lResult[0..lOutPos]. idup;1443 return lResult[0..lOutPos].dup; 1453 1444 } 1454 1445 … … 1507 1498 // Do a simple test to see if any expansion is required. 1508 1499 lLine = std.utf.toUTF32(pLine); 1509 version(D_Version2) 1510 { 1511 lPos = find(lLine.idup, "%"d[], 0); 1512 lDPos = find(lLine.idup, "$"d[], 0); 1513 } 1514 else 1515 { 1516 lPos = find(lLine, "%"d[], 0); 1517 lDPos = find(lLine, "$"d[], 0); 1518 } 1500 lPos = find(lLine, "%"d[], 0); 1501 lDPos = find(lLine, "$"d[], 0); 1519 1502 if (lPos == -1 && lDPos == -1) 1520 1503 { … … 1641 1624 1642 1625 lKeyVal.length = 2; 1643 version(D_Version2) 1644 { 1645 lEqPos = find(lSymName.idup, "="d[], 0); 1646 } 1647 else 1648 { 1649 lEqPos = find(lSymName, "="d[], 0); 1650 } 1626 lEqPos = find(lSymName, "="d[], 0); 1651 1627 if (lEqPos != -1) 1652 1628 { trunk/Source/util/str_bn.d
r53 r54 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 3 120;4 long auto_build_number = 3239;
