@@ -33,8 +33,13 @@ public Exception Run(IOptionPack o)
33
33
ignores = o . Ignores . Split ( ';' ) . Select ( x => new Regex ( x , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ) . ToList ( ) ;
34
34
}
35
35
36
+ Regex trim = null ;
37
+ if ( ! string . IsNullOrWhiteSpace ( o . Trim ) )
38
+ {
39
+ trim = new Regex ( $ "^{ o . Trim } ") ;
40
+ }
36
41
37
- using ( var tempDirectory = new TempDirectory ( "packer" ) )
42
+ using ( var tempDirectory = new TempDirectory ( ) )
38
43
{
39
44
try
40
45
{
@@ -57,11 +62,11 @@ public Exception Run(IOptionPack o)
57
62
58
63
if ( Directory . Exists ( absPath ) )
59
64
{
60
- ProcessDirectory ( absPath , o . Trim , o . Prefix , tempDirectory . TempDirectoryPath , ignores ) ;
65
+ ProcessDirectory ( absPath , trim , o . Prefix , tempDirectory . TempDirectoryPath , ignores ) ;
61
66
}
62
67
else if ( File . Exists ( absPath ) )
63
68
{
64
- CreateAsset ( absPath , o . Trim , o . Prefix , tempDirectory . TempDirectoryPath ) ;
69
+ CreateAsset ( absPath , trim , o . Prefix , tempDirectory . TempDirectoryPath ) ;
65
70
}
66
71
else
67
72
{
@@ -80,7 +85,7 @@ public Exception Run(IOptionPack o)
80
85
}
81
86
}
82
87
83
- private void CreateAsset ( string inFileOrDirectory , string trim , string prefix , string tempDirectoryPath )
88
+ private void CreateAsset ( string inFileOrDirectory , Regex trim , string prefix , string tempDirectoryPath )
84
89
{
85
90
// a.txt
86
91
// b/
@@ -126,14 +131,20 @@ private void CreateAsset(string inFileOrDirectory, string trim, string prefix, s
126
131
}
127
132
128
133
// guidDir/pathname
129
- var pathname = inFileOrDirectory . Substring ( Environment . CurrentDirectory . Replace ( Path . DirectorySeparatorChar , '/' ) . Length ) . Trim ( '/' ) ;
134
+ var pathname = inFileOrDirectory . Substring ( Environment . CurrentDirectory . Replace ( Path . DirectorySeparatorChar , '/' ) . Length ) . Trim ( '/' ) ;
135
+ if ( trim != null )
136
+ {
137
+ pathname = $ "{ prefix } { trim . Replace ( pathname , "" , 1 ) } ";
138
+ }
139
+ else
140
+ {
141
+ pathname = $ "{ prefix } { pathname } ";
142
+ }
130
143
131
- pathname = new Regex ( $ "^{ trim } ") . Replace ( pathname , "" , 1 ) ;
132
- pathname = $ "{ prefix } { pathname } ";
133
144
File . WriteAllText ( Path . Combine ( tempDirectoryPath , guid , "pathname" ) , pathname ) ;
134
145
}
135
146
136
- private void ProcessDirectory ( string inputDirectory , string trim , string prefix , string tempDirectoryPath , List < Regex > ignores )
147
+ private void ProcessDirectory ( string inputDirectory , Regex trim , string prefix , string tempDirectoryPath , List < Regex > ignores )
137
148
{
138
149
foreach ( var entry in Directory . EnumerateFileSystemEntries ( inputDirectory , "*" , SearchOption . AllDirectories ) )
139
150
{
0 commit comments