// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#if NET_2_0
+
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.IO;
namespace Microsoft.Build.BuildEngine {
public void Scan ()
{
- Hashtable temporaryItems;
- string[] splittedInclude, splittedExclude;
-
+ Dictionary <string, bool> excludedItems;
+ List <string> includedItems;
+ string[] splitInclude, splitExclude;
+
if (includes == null)
throw new ArgumentNullException ("Includes");
if (excludes == null)
if (baseDirectory == null)
throw new ArgumentNullException ("BaseDirectory");
- temporaryItems = new Hashtable ();
+ excludedItems = new Dictionary <string, bool> ();
+ includedItems = new List <string> ();
- splittedInclude = includes.Split (';');
- splittedExclude = excludes.Split (';');
+ splitInclude = includes.Split (';');
+ splitExclude = excludes.Split (';');
- foreach (string si in splittedInclude) {
- ProcessInclude (si, temporaryItems);
- }
if (excludes != String.Empty) {
- foreach (string si in splittedExclude) {
- ProcessExclude (si, temporaryItems);
+ foreach (string si in splitExclude) {
+ ProcessExclude (si, excludedItems);
}
}
-
- matchedFilenames = new string [temporaryItems.Count];
- int i = 0;
- foreach (DictionaryEntry de in temporaryItems)
- matchedFilenames [i++] = (string) de.Value;
+ if (includes != String.Empty) {
+ foreach (string si in splitInclude) {
+ ProcessInclude (si, excludedItems, includedItems);
+ }
+ }
+
+ matchedFilenames = includedItems.ToArray ();
}
- private void ProcessInclude (string name, Hashtable temporaryItems)
+ private void ProcessInclude (string name, Dictionary <string, bool> excludedItems, List <string> includedItems)
{
string[] separatedPath;
FileInfo[] fileInfo;
-
- if (name.IndexOf ('?') == -1 && name.IndexOf ('*') == -1)
- temporaryItems.Add (Path.GetFullPath (name), name);
- else {
+
+ if (name.IndexOf ('?') == -1 && name.IndexOf ('*') == -1) {
+ if (!excludedItems.ContainsKey (Path.GetFullPath(name)))
+ includedItems.Add (name);
+ } else {
if (name.Split (Path.DirectorySeparatorChar).Length > name.Split (Path.AltDirectorySeparatorChar).Length) {
separatedPath = name.Split (Path.DirectorySeparatorChar);
} else {
return;
fileInfo = ParseIncludeExclude (separatedPath, 0, baseDirectory);
foreach (FileInfo fi in fileInfo)
- temporaryItems.Add (fi.FullName, fi.FullName);
+ if (!excludedItems.ContainsKey (fi.FullName))
+ includedItems.Add (fi.FullName);
}
}
- private void ProcessExclude (string name, Hashtable temporaryItems)
+ private void ProcessExclude (string name, Dictionary <string, bool> excludedItems)
{
string[] separatedPath;
FileInfo[] fileInfo;
if (name.IndexOf ('?') == -1 && name.IndexOf ('*') == -1) {
- if (temporaryItems.Contains (Path.GetFullPath (name)))
- temporaryItems.Remove (Path.GetFullPath (name));
+ if (!excludedItems.ContainsKey (Path.GetFullPath (name)))
+ excludedItems.Add (Path.GetFullPath (name), true);
} else {
if (name.Split (Path.DirectorySeparatorChar).Length > name.Split (Path.AltDirectorySeparatorChar).Length) {
separatedPath = name.Split (Path.DirectorySeparatorChar);
return;
fileInfo = ParseIncludeExclude (separatedPath, 0, baseDirectory);
foreach (FileInfo fi in fileInfo)
- if (temporaryItems.Contains (fi.FullName))
- temporaryItems.Remove (fi.FullName);
+ if (!excludedItems.ContainsKey (fi.FullName))
+ excludedItems.Add (fi.FullName, true);
}
}
} else {
DirectoryInfo[] di;
FileInfo[] fi;
- ArrayList fileInfos = new ArrayList ();
+ List <FileInfo> fileInfos = new List <FileInfo> ();
if (input [ptr] == ".") {
di = new DirectoryInfo [1];
di [0] = directory;
}
}
-}
\ No newline at end of file
+}
+
+#endif