Changeset 217
- Timestamp:
- 07/15/08 07:28:15 (6 months ago)
- Files:
-
- trunk/bridge/php/String.d (modified) (21 diffs)
- trunk/core/Array.d (modified) (38 diffs)
- trunk/io/ContentScan.d (modified) (7 diffs)
- trunk/io/Digest.d (modified) (14 diffs)
- trunk/io/Path.d (modified) (6 diffs)
- trunk/io/compress (added)
- trunk/io/compress/Zip.d (added)
- trunk/lab/Misc.d (modified) (7 diffs)
- trunk/lab/Qzip.d (deleted)
- trunk/lab/SoftwareConfig.d (modified) (15 diffs)
- trunk/lib/dwin.lib (modified) (previous)
- trunk/math/bigint/Prime.d (modified) (3 diffs)
- trunk/net/Net.d (modified) (2 diffs)
- trunk/net/Uri.d (modified) (1 diff)
- trunk/sys/win32/Process.d (modified) (3 diffs)
- trunk/sys/win32/Registry.d (modified) (9 diffs)
- trunk/sys/win32/SpecPath.d (modified) (13 diffs)
- trunk/sys/win32/com/Core.d (modified) (24 diffs)
- trunk/text/Properties.d (modified) (23 diffs)
- trunk/text/Util.d (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/bridge/php/String.d
r154 r217 3 3 4 4 /******************************************************************************* 5 5 6 6 Copyright: Copyright (c) 2007 (yidabu g m a i l at com) All rights reserved 7 7 … … 22 22 23 23 import dwin.text.Unicode : toLower; 24 24 25 25 import tango.text.Unicode, 26 26 tango.core.Traits, … … 32 32 import Unicode = tango.text.Unicode; 33 33 import Util = tango.text.Util; 34 34 35 35 36 36 … … 50 50 if(!str.length) 51 51 return result; 52 52 53 53 auto crc = getCrc32(str); 54 54 result = Integer.toInt(crc.hexDigest, 16); 55 55 56 56 return result; 57 57 } … … 67 67 çŽ ïŒèæåé£äžªå 68 68 çŽ å°å 69 å« string çå©äœéšåã 69 å« string çå©äœéšåã 70 70 71 71 åŠæ separator 䞺空å笊䞲ïŒ""ïŒïŒexplode() å°è¿å FALSEãåŠæ separator æå 72 72 å«çåŒåš string äžæŸäžå°ïŒé£ä¹ explode() å°è¿åå 73 73 å« string å䞪å 74 çŽ çæ°ç»ã 74 çŽ çæ°ç»ã 75 75 76 76 åŠæ limit åæ°æ¯èŽæ°ïŒåè¿åé€äºæåç -limit 䞪å 77 77 çŽ å€çææå 78 çŽ ãæ€ç¹æ§æ¯ PHP 5.1.0 äžæ°å¢çã 78 çŽ ãæ€ç¹æ§æ¯ PHP 5.1.0 äžæ°å¢çã 79 79 80 80 */ 81 81 char[][] explode ( char[] separator , char[] src, int limit = int.max ) 82 { 82 { 83 83 if(!separator.length) 84 84 return null; 85 85 86 86 //if( !Util.containsPattern(src, separator) ) 87 87 //return [src]; 88 88 89 89 char[][] result; 90 90 91 91 auto i = Util.locatePattern (src, separator); 92 92 while (i != src.length ) … … 95 95 if(result.length >= limit -1) 96 96 break; 97 97 98 98 result ~= src[0 .. i]; 99 99 src = src [i + separator.length .. $]; 100 i = Util.locatePattern (src, separator); 101 } 102 100 i = Util.locatePattern (src, separator); 101 } 102 103 103 if(limit < 0 ) 104 104 { … … 108 108 else 109 109 result ~= src; 110 110 111 111 return result; 112 } 112 } 113 113 debug unittest 114 114 { … … 117 117 assert ( pieces[0] == "piece1" ); 118 118 assert ( pieces[1] == "piece2" ); 119 119 120 120 auto str = "one|two|three|four"; 121 121 auto result = explode("|", str, 2); 122 122 assert( result.length == 2 && result[0] == "one" && result[1] == "two|three|four" ); 123 123 124 124 // èŽæ°ç limitïŒèª PHP 5.1 èµ·ïŒ 125 125 result = explode("|", str, -1); 126 126 assert( result.length == 3 && result[0] == "one" && result[1] == "two" && result[2] == "three" ); 127 127 128 128 } 129 129 // … … 132 132 133 133 /** 134 The default mode, ENT_COMPAT, is the backwards compatible mode which only translates the double-quote character and leaves the single-quote untranslated. If ENT_QUOTES is set, both single and double quotes are translated and if ENT_NOQUOTES is set neither single nor double quotes are translated. 135 '&' (ampersand) becomes '&' 136 '"' (double quote) becomes '"' when ENT_NOQUOTES is not set. 137 ''' (single quote) becomes ''' only when ENT_QUOTES is set. 138 '<' (less than) becomes '<' 139 '>' (greater than) becomes '>' 134 The default mode, ENT_COMPAT, is the backwards compatible mode which only translates the double-quote character and leaves the single-quote untranslated. If ENT_QUOTES is set, both single and double quotes are translated and if ENT_NOQUOTES is set neither single nor double quotes are translated. 135 '&' (ampersand) becomes '&' 136 '"' (double quote) becomes '"' when ENT_NOQUOTES is not set. 137 ''' (single quote) becomes ''' only when ENT_QUOTES is set. 138 '<' (less than) becomes '<' 139 '>' (greater than) becomes '>' 140 140 */ 141 141 … … 151 151 str = Util.substitute(str, "'", "'"); 152 152 break; 153 case ENT_COMPAT : //only translates the double-quote 153 case ENT_COMPAT : //only translates the double-quote 154 154 str = Util.substitute(str, "\"", """); 155 155 case ENT_NOQUOTES : //both not 156 156 break; 157 157 } 158 158 159 159 return str; 160 160 } … … 163 163 char[] result = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); 164 164 assert( result == "<a href='test'>Test</a>" ); 165 166 165 166 167 167 } 168 168 // … … 202 202 203 203 /** 204 substr() returns the portion of string specified by the start and length parameters. 205 206 If start is non-negative, the returned string will start at the start'th position in string, counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so forth. 207 208 If start is negative, the returned string will start at the start'th character from the end of string. 209 210 If length is given and is positive, the string returned will contain at most length characters beginning from start (depending on the length of string). If string is less than or equal to start characters long, FALSE will be returned. 211 212 If length is given and is negative, then that many characters will be omitted from the end of string (after the start position has been calculated when a start is negative). If start denotes a position beyond this truncation, an empty string will be returned. 204 substr() returns the portion of string specified by the start and length parameters. 205 206 If start is non-negative, the returned string will start at the start'th position in string, counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so forth. 207 208 If start is negative, the returned string will start at the start'th character from the end of string. 209 210 If length is given and is positive, the string returned will contain at most length characters beginning from start (depending on the length of string). If string is less than or equal to start characters long, FALSE will be returned. 211 212 If length is given and is negative, then that many characters will be omitted from the end of string (after the start position has been calculated when a start is negative). If start denotes a position beyond this truncation, an empty string will be returned. 213 213 214 214 … … 221 221 if(start >= str.length) 222 222 return null; 223 223 224 224 if(start < 0) 225 225 start = str.length + start; 226 226 227 227 if(len < 0) 228 228 { … … 236 236 len = str.length - start; 237 237 } 238 238 239 239 return str[start .. start + len]; 240 240 } … … 242 242 debug unittest 243 243 { 244 244 245 245 char[] str = "abcdef"; 246 246 assert( substr(str, 1) == "bcdef" ); … … 249 249 assert( substr(str, 0, 8) == "abcdef" ); 250 250 assert( substr(str, -1, 1) == "f" ); 251 251 252 252 assert( substr(str, -1) == "f" ); 253 253 assert( substr(str, -2) == "ef" ); … … 269 269 270 270 /** 271 strpos -- Find position of first occurrence of a string 271 strpos -- Find position of first occurrence of a string 272 272 Description 273 273 274 Returns the numeric position of the first occurrence of needle in the haystack string. 275 Unlike the strrpos(), this function can take a full string as the needle parameter and the entire string will be used. 274 Returns the numeric position of the first occurrence of needle in the haystack string. 275 Unlike the strrpos(), this function can take a full string as the needle parameter and the entire string will be used. 276 276 277 277 TODO: D can not have two types of return value : bool and int … … 291 291 { 292 292 // Provides: <body text='black'> 293 assert( str_replace("%body%", "black", "<body text='%body%'>") == "<body text='black'>" ); 293 assert( str_replace("%body%", "black", "<body text='%body%'>") == "<body text='black'>" ); 294 294 } 295 295 // … … 312 312 { 313 313 char[64] tmp; 314 return Integer.format(tmp, number, Integer.Style.Hex).dup;314 return Integer.format(tmp, number, "x").dup; 315 315 } 316 316 char[] dechex ( char[] str ) … … 325 325 assert(dechex(10) == "a"); 326 326 assert(dechex(47) == "2f"); 327 327 328 328 } 329 329 // … … 343 343 assert( is_numeric('1') ); 344 344 assert( !is_numeric('a') ); 345 assert( is_numeric(56789) ); 346 } 347 348 349 345 assert( is_numeric(56789) ); 346 } 347 348 349 trunk/core/Array.d
r160 r217 2 2 3 3 /******************************************************************************* 4 4 5 5 Copyright: Copyright (c) 2007 (yidabu g m a i l at com) All rights reserved 6 6 … … 19 19 * 20 20 * 21 * 21 * 22 22 */ 23 23 module dwin.core.Array ; 24 24 25 25 26 private import tango.core.Array, 27 tango.core.Traits, 28 tango.math.Random, 29 tango.core.Vararg; 26 27 import tango.core.Array; 28 private import tango.core.Traits; 29 //tango.math.Kiss, 30 private import tango.core.Vararg; 30 31 31 32 private import tango.stdc.string : memmove ; 32 33 private import tango.text.Util : substitute; 33 34 34 35 private import dwin.core.Ctfe : IsLessEqual, IsMoreEqual, IsMore; 35 36 36 37 version (ArrayVerbose) 37 38 version (ArrayVerbose) 38 39 private import tango.util.log.Trace; 39 40 40 41 41 42 … … 62 63 * The index of the nth match or buf.length if no match was found. 63 64 */ 64 65 65 66 //modified from tango.core.Array.find 66 67 template findNth_( Elem, Pred = IsEqual!(Elem) ) … … 141 142 unittest 142 143 { 143 144 144 145 int[] foo = [1, 2, 3, 2, 4, 2]; 145 assert( findNth(foo, 5) == 6U ); //not found 146 assert( findNth(foo, 5) == 6U ); //not found 146 147 assert( findNth(foo, 2) == 1U ); //first 2, index is 1 147 assert( findNth(foo, 2, 2U) == 3U ); 148 assert( findNth(foo, 2, 2U) == 3U ); 148 149 assert( findNth(foo, 2, 3U) == 5U ); 149 150 assert( findNth(foo, 5, 2U) == 6U ); //not found 150 151 151 152 char[] bar = "abcabc"; 152 153 assert( findNth(bar, "a") == 0U ); … … 154 155 assert( findNth(bar, 'a', 2U) == 3U ); 155 156 assert( findNth(bar, "a", 2U) == 3U ); 156 157 157 158 assert( findNth(bar, "a", 3U) == 6U ); //not found 158 159 assert( findNth(bar, "d") == 6U ); //not found … … 160 161 assert( findNth(bar, 'd', 2U) == 6U ); //not found 161 162 assert( findNth(bar, "d", 2U) == 6U ); //not found 162 163 163 164 } 164 165 } … … 273 274 assert( rfindNth(s, "abc") == 6U); 274 275 assert( rfindNth(s, "abc", 2U) == 3U); 275 276 276 277 assert( rfindNth(s, "abc", 3U) == 0U); 277 278 278 279 assert( rfindNth(s, 'a') == 6U); 279 280 assert( rfindNth(s, 'a', 2U) == 3U); 280 281 assert( rfindNth(s, 'a', 3U) == 0U); 281 282 282 283 assert( rfindNth(s, 'd') == 9U); //not found 283 284 assert( rfindNth(s, "d") == 9U); //not found 284 285 285 286 } 286 287 } … … 307 308 { 308 309 static assert( isCallableType!(Pred) ); 309 310 310 311 Buf replaceNth( Buf buf, Elem pat, Elem val, uint nth, Pred pred ) 311 312 { … … 313 314 if( where == buf.length ) 314 315 return buf; 315 return buf[0..where] ~ val ~ buf[where + pat.length .. $]; 316 return buf[0..where] ~ val ~ buf[where + pat.length .. $]; 316 317 } 317 318 } … … 328 329 r = replaceNth(s, "ab", "AB", 3U); 329 330 assert ( r == "ababAB" ); 330 331 331 332 // not found 332 333 r = replaceNth(s, "ac", "AB"); 333 assert ( r == "ababab" ); 334 assert ( r == "ababab" ); 334 335 r = replaceNth(s, "ac", "AB", 2U); 335 336 assert ( r == "ababab" ); 336 337 337 338 r = replaceNth(s, 'a', 'A', 1U); 338 assert ( r == "Ababab" ); 339 assert ( r == "Ababab" ); 339 340 r = replaceNth(s, 'c', 'C', 2U); 340 assert ( r == "ababab" ); 341 341 assert ( r == "ababab" ); 342 342 343 } 343 344 } … … 364 365 { 365 366 static assert( isCallableType!(Pred) ); 366 367 367 368 Buf rreplaceNth( Buf buf, Elem pat, Elem val, uint nth, Pred pred ) 368 369 { … … 370 371 if( where == buf.length ) 371 372 return buf; 372 return buf[0..where] ~ val ~ buf[where + pat.length .. $]; 373 return buf[0..where] ~ val ~ buf[where + pat.length .. $]; 373 374 } 374 375 } … … 385 386 r = rreplaceNth(s, "ab", "AB", 3U); 386 387 assert ( r == "ABabab" ); 387 388 388 389 // not found 389 390 r = rreplaceNth(s, "ac", "AB"); 390 assert ( r == "ababab" ); 391 assert ( r == "ababab" ); 391 392 r = rreplaceNth(s, "ac", "AB", 2U); 392 393 assert ( r == "ababab" ); 393 394 394 395 r = rreplaceNth(s, 'a', 'A', 1U); 395 assert ( r == "ababAb" ); 396 assert ( r == "ababAb" ); 396 397 r = rreplaceNth(s, "c", "C", 2U); 397 assert ( r == "ababab" ); 398 assert ( r == "ababab" ); 398 399 } 399 400 } … … 407 408 408 409 char[] replaceSeries(char[] buf, ... ) 409 { 410 { 410 411 alias char[] t; 411 412 for(uint i = 0; i < _arguments.length -1; i += 2 ) … … 434 435 435 436 //////////////////////////////////////////////////////////////////////////////// 436 // Remove by index 437 // Remove by index 437 438 //////////////////////////////////////////////////////////////////////////////// 438 439 … … 440 441 * Performs a linear scan of buf from $(LB)0 .. buf.length$(RB), moving all 441 442 * elements matching index to the end of the sequence. The relative order of 442 * elements not matching index will be preserved. 443 * elements not matching index will be preserved. 443 444 * Params: 444 445 * buf = The array to scan. This parameter is not marked 'inout' … … 449 450 * inx = The pattern index to match against. 450 451 * 451 * Returns:xxx 452 * Returns:xxx 452 453 * The result array. 453 454 */ 454 455 455 456 template removeByIndex( Buf ) 456 457 { … … 459 460 { 460 461 alias ElemTypeOf!(Buf) Elem; 461 462 if( !buf.length || inx >= buf.length ) 462 463 if( !buf.length || inx >= buf.length ) 463 464 return buf; 464 465 if (inx != buf.length - 1) 465 466 if (inx != buf.length - 1) 466 467 { 467 468 memmove(&(buf[inx]), &(buf[inx + 1]), Elem.sizeof * (buf.length - inx - 1)); 468 469 } 469 470 470 471 buf.length = buf.length - 1; 471 472 return buf; … … 494 495 * Performs a linear scan of buf from $(LB)0 .. buf.length$(RB), moving all 495 496 * elements matching index to the end of the sequence. The relative order of 496 * elements not matching index will be preserved. 497 * elements not matching index will be preserved. 497 498 * Params: 498 499 * buf = The array to scan. This parameter is not marked 'inout' … … 508 509 */ 509 510 510 template removeNth (Buf, Pat) 511 template removeNth (Buf, Pat) 511 512 { 512 513 Buf removeNth (Buf buf, Pat pat, uint nth = 1) … … 514 515 size_t index = findNth(buf, pat, nth); 515 516 516 if (index != buf.length) 517 if (index != buf.length) 517 518 { 518 519 buf.removeByIndex(index); … … 525 526 unittest 526 527 { 527 528 528 529 int[] foo = [1, 2, 3, 2, 3]; 529 530 foo = foo.removeNth(2); 530 assert(foo == [1, 3, 2, 3]); 531 assert(foo == [1, 3, 2, 3]); 531 532 foo = foo.removeNth(3, 2U); 532 533 assert(foo == [1, 3, 2]); 533 534 534 535 } 535 536 } … … 547 548 Elem[] replacePairs (Elem) (ref Elem[] buf, Elem[Elem] pairs) 548 549 { 549 //cashew.utils.Array 550 //cashew.utils.Array 550 551 Elem* peer ; 551 552 … … 565 566 auto pairs = assoc!(int, int)( 566 567 [1, 2, 3] , 567 [4, 5, 6] 568 [4, 5, 6] 568 569 ); 569 570 foo.replacePairs(pairs); 570 assert(foo == [4, 5, 6, 4, 5, 6, 4, 5, 6]); 571 assert(foo == [4, 5, 6, 4, 5, 6, 4, 5, 6]); 571 572 } 572 573 } … … 581 582 * Update/modify all elements of an array. 582 583 */ 583 template apply (Elem, Pred) 584 template apply (Elem, Pred) 584 585 { 585 586 static assert( isCallableType!(Pred) ); 586 587 587 588 Elem[] apply (ref Elem[] buf, Pred pred) 588 { 589 foreach (ref cur; buf) 589 { 590 foreach (ref cur; buf) 590 591 pred(cur); 591 592 return buf; … … 595 596 { 596 597 unittest 597 { 598 { 598 599 int[] foo = [1, 3, 5, 7]; 599 600 foo.apply((ref int n) { n++; }); … … 619 620 ElemV[ElemK] result ; 620 621 621 foreach (i, x; keys) 622 foreach (i, x; keys) 622 623 { 623 624 result[x] = values[i]; … … 626 627 } 627 628 628 debug( UnitTest ) 629 { 630 unittest 629 debug( UnitTest ) 630 { 631 unittest 631 632 { 632 633 auto foo = assoc!(int, char)( … … 647 648 /// Return the maximum value of an array. 648 649 T max(T)(T[] array) 649 { 650 { 650 651 /* 651 652 T m = array[0]; 652 653 foreach (T a; array) 653 654 if (a>m) 654 m=a; 655 m=a; 655 656 return m; 656 657 */ … … 671 672 { 672 673 static assert( isIntegerType!(V), "array value type must been integer type" ); 673 674 if(!array.length) 674 675 if(!array.length) 675 676 return null; 676 677 677 678 678 679 K[] result ; 679 680 long i = -(long.max); … … 683 684 { 684 685 i = v; 685 result = k; 686 result = k; 686 687 } 687 688 } 688 689 689 690 return result; 690 691 } … … 709 710 /// Return the minimum value of an array. 710 711 T min(T)(T[] array) 711 { 712 { 712 713 //yage.core.array; 713 714 T m = array[0]; 714 715 foreach (T a; array) 715 716 if (a<m) 716 m=a; 717 m=a; 717 718 return m; 718 719 } … … 726 727 /** 727 728 * Is the array ordered? 728 */ 729 */ 729 730 template isOrdered_( T, Pred = IsMoreEqual!(T) ) 730 731 { 731 732 static assert( isCallableType!(Pred) ); 732 733 733 734 bool fn (T[] array, Pred pred = Pred.init ) 734 { 735 { 735 736 if (array.length <= 1) 736 737 return true; 737 738 738 739 for (int i=0; i<array.length-1; i++) 739 740 if( !pred(array[i+1], array[i]) ) … … 746 747 { 747 748 bool isOrdered (T[] array ) 748 { 749 { 749 750 return isOrdered_!(T).fn(array); 750 } 751 } 751 752 } 752 753 template isOrdered( T, Pred ) 753 754 { 754 755 bool isOrdered (T[] array, Pred pred ) 755 { 756 { 756 757 return isOrdered_!(T, Pred).fn(array, pred); 757 } 758 } 758 759 } 759 760 debug( UnitTest ) … … 774 775 Examples: 775 776 --- 776 randomValue(["a","b","c"]); 777 randomValue(["a","b","c"]); 777 778 --- 778 779 */ … … 780 781 T randomValue(T)(T[] arr) 781 782 { 782 return arr[ Random.shared.next(0, arr.length) ];783 return arr[ Kiss().next(0, arr.length) ]; 783 784 } 784 785 */ 785 786 786 787 //////////////////////////////////////////////////////////////////////////////// 787 // push 788 // push 788 789 //////////////////////////////////////////////////////////////////////////////// 789 790 /*********************************************************************************** … … 792 793 int push (Elem) (ref Elem[] buf, Elem[] bale ...) 793 794 { 794 //cashew.utils.Array 795 //cashew.utils.Array 795 796 buf ~= bale; 796 797 return buf.length; … … 800 801 unittest 801 802 { 802 803 803 804 int[] foo = [1, 2, 3]; 804 805 foo.push(4, 5); 805 806 assert(foo == [1, 2, 3, 4, 5]); 806 807 } 808 } 809 // 807 808 } 809 } 810 // trunk/io/ContentScan.d
r154 r217 2 2 3 3 /******************************************************************************* 4 4 5 5 Copyright: Copyright (c) 2007 (yidabu g m a i l at com) All rights reserved 6 6 … … 24 24 25 25 /******************************************************************************* 26 26 27 27 tango.text.Regex is simple, not powerful, may instead of pcre in the future. 28 28 29 29 Example: 30 30 --- … … 35 35 //scan.contain = r"\lab\"; 36 36 auto result = scan.scan(path); 37 37 38 38 auto contentScan = new ContentScan(); 39 39 contentScan.regexContain = r"[aA]uthors?:[^\r\n]+?yidabu[^\r\n]+"; 40 40 contentScan.replaceWith = "Authors: yidabu ( D Programming Language China : http://www.d-programming-language-china.org/ )"; 41 41 contentScan.scan(result.files); 42 43 Stdout.formatln ("\n{} Relpaced Files", contentScan.find.length); 42 43 Stdout.formatln ("\n{} Relpaced Files", contentScan.find.length); 44 44 foreach(file; contentScan.find) 45 45 { 46 46 Stdout(file).newline; 47 47 } 48 49 Stdout.formatln ("\n{} Files no Replaced", contentScan.notfind.length); 48 49 Stdout.formatln ("\n{} Files no Replaced", contentScan.notfind.length); 50 50 foreach(file; contentScan.notfind) 51 51 { 52 52 Stdout(file).newline; 53 } 54 53 } 54 55 55 --- 56 56 … … 58 58 59 59 60 class ContentScan 60 class ContentScan 61 61 { 62 62 /// exactly string … … 64 64 /// exactly excluded string 65 65 char[] exclude; 66 66 67 67 /// See_Also: tango.text.Regex 68 68 char[] regexContain; 69 69 char[] regexExclude; 70 70 71 71 Regex regexContain_; 72 72 Regex regexExclude_; 73 73 74 74 char[] replaceWith; 75 75 76 76 FilePath[] find; 77 77 FilePath[] notfind; 78 78 79 79 ContentScan scan(FilePath[] files) 80 80 { 81 81 if(!files.length) 82 82 return this; 83 83 84 84 if(regexContain.length) 85 85 regexContain_ = Regex(regexContain); 86 86 if(regexExclude.length) 87 87 regexExclude_ = Regex(regexExclude); 88 88 89 89 foreach(file; files) 90 90 { 91 char[] src = cast(char[]) ( (new File(file )).read );92 91 char[] src = cast(char[]) ( (new File(file.dup.native.toString)).read ); 92 93 93 if( (contain.length && !src.containsPattern(contain)) || 94 94 (exclude.length && src.containsPattern(exclude)) || 95 95 (regexContain_ && !regexContain_.test(src)) || 96 (regexExclude_ && regexExclude_.test(src)) 96 (regexExclude_ && regexExclude_.test(src)) 97 97 ) 98 98 { … … 100 100 continue; 101 101 } 102 102 103 103 find ~= file.dup.native; 104 104 105 105 if( replaceWith.length && (regexContain.length || contain.length) ) 106 106 { … … 109 109 else if( contain.length ) 110 110 src = substitute(src, contain, replaceWith); 111 (new File(file )).write(src);111 (new File(file.dup.native.toString)).write(src); 112 112 } 113 113 }//foreach 114 114 115 115 return this; 116 116 }//scan 117 117 118 118 }//ContentScan trunk/io/Digest.d
r154 r217 3 3 4 4 /******************************************************************************* 5 5 6 6 Copyright: Copyright (c) 2007 (yidabu g m a i l at com) All rights reserved 7 7 … … 26 26 tango.io.FilePath, 27 27 tango.io.File; 28 28 29 29 30 30 //MySQLæäŸäº4äžªåœæ°çšäºååžå å¯ïŒPASSWORD, ENCRYPT, SHA1åMD5, æä»¥è¿éè³å°èŠæäŸsha1åmd5çå®ç° … … 35 35 if(!path.exists) 36 36 return null; 37 ubyte[] result = cast(ubyte[]) (new File(path )).read;37 ubyte[] result = cast(ubyte[]) (new File(path.dup.native.toString())).read; 38 38 return getMd5( result ); 39 39 } … … 53 53 debug(UnitTest) unittest 54 54 { 55 55 56 56 static char[][] strings = 57 57 [ … … 75 75 "57edf4a22be3c955ac49da2e2107b67a" 76 76 ]; 77 77 78 78 foreach(k,v; strings) 79 79 { 80 80 assert(getMd5(v).hexDigest == results[k] ); 81 81 } 82 82 83 83 } 84 84 //getMd5 … … 90 90 if(!path.exists) 91 91 return null; 92 ubyte[] result = cast(ubyte[]) (new File(path )).read;92 ubyte[] result = cast(ubyte[]) (new File(path.dup.native.toString)).read; 93 93 return getCrc32( result ); 94 94 } … … 113 113 if(!path.exists) 114 114 return null; 115 ubyte[] result = cast(ubyte[]) (new File(path )).read;115 ubyte[] result = cast(ubyte[]) (new File(path.dup.native.toString)).read; 116 116 return getTiger( result ); 117 117 } … … 154 154 foreach(k,v; strings) 155 155 assert(getTiger(v).hexDigest == results[k]); 156 156 157 157 } 158 158 //getTiger … … 164 164 if(!path.exists) 165 165 return null; 166 ubyte[] result = cast(ubyte[]) (new File(path )).read;166 ubyte[] result = cast(ubyte[]) (new File(path.dup.native.toString)).read; 167 167 return getSha1( result ); 168 168 } … … 183 183 { 184 184 185 185 186 186 } 187 187 //getSha1 … … 192 192 if(!path.exists) 193 193 return null; 194 ubyte[] result = cast(ubyte[]) (new File(path )).read;194 ubyte[] result = cast(ubyte[]) (new File(path.dup.native.toString)).read; 195 195 return getSha256( result ); 196 196 } … … 224 224 foreach(k,v; strings) 225 225 assert(getSha256(v).hexDigest == results[k]); 226 226 227 227 } 228 228 //getSha256 … … 235 235 if(!path.exists) 236 236 return null; 237 ubyte[] result = cast(ubyte[]) (new File(path )).read;237 ubyte[] result = cast(ubyte[]) (new File(path.dup.native.toString)).read; 238 238 return getSha512( result ); 239 239 } … … 269 269 foreach(k,v; strings) 270 270 assert(getSha512(v).hexDigest == results[k]); 271 271 272 272 } 273 273 //getSha512 trunk/io/Path.d
r172 r217 3 3 4 4 /******************************************************************************* 5 5 6 6 copyright: Copyright (c) 2007 (yidabu g m a i l at com) All rights reserved 7 7 … … 14 14 *******************************************************************************/ 15 15 16 module dwin.io. FilePath;16 module dwin.io.Path; 17 17 18 18 19 19 import tango.io.FilePath; 20 20 21 21 version(Win32): 22 22 … … 29 29 30 30 */ 31 bool removeDirTree(char[] dir) 32 { 31 bool removeDirTree(char[] dir) 32 { 33 33 alias SHFILEOPSTRUCTW SHFILEOPSTRUCT; 34 SHFILEOPSTRUCT FileOp; 35 36 FileOp.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; 37 FileOp.hNameMappings = null; 38 FileOp.hwnd = null; 39 FileOp.lpszProgressTitle = null; 40 FileOp.pFrom = toString16zz(dir); 41 FileOp.pTo = null; 42 FileOp.wFunc = FO_DELETE; 43 //FileOp.fAnyOperationsAborted = FALSE; 44 34 SHFILEOPSTRUCT FileOp; 35 36 FileOp.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; 37 FileOp.hNameMappings = null; 38 FileOp.hwnd = null; 39 FileOp.lpszProgressTitle = null; 40 FileOp.pFrom = toString16zz(dir); 41 FileOp.pTo = null; 42 FileOp.wFunc = FO_DELETE; 43 //FileOp.fAnyOperationsAborted = FALSE; 44 45 45 bool result; 46 46 if( SHFileOperationW(&FileOp) == 0 ) 47 47 if( FileOp.fAnyOperationsAborted == FALSE ) 48 result = true; 48 result = true; 49 49 return result; 50 51 } 50 51 } 52 52 53 53 /** … … 60 60 Tango solution: 61 61 p = p.pop.replace('\\', '/'); 62
