/[AnywhereTS-MSSQL]/trunk/Tools/ATSClientManager/ATSClientManager/ATSClientFilesCollection.cs
ViewVC logotype

Annotation of /trunk/Tools/ATSClientManager/ATSClientManager/ATSClientFilesCollection.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 341 - (hide annotations) (download)
Mon Aug 27 22:56:48 2012 UTC (7 years, 11 months ago) by william
File size: 2746 byte(s)

1 william 335 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5 william 341 using System.IO;
6 william 335 namespace AnywhereTS.ATSClientManager
7     {
8     public static class ATSClientFilesCollection
9     {
10     private static Dictionary<ATSClientFileTypes, string> collection;
11    
12     static ATSClientFilesCollection()
13     {
14     collection = new Dictionary<ATSClientFileTypes, string>
15     {
16     {ATSClientFileTypes.ClientFileSystem, "initrd"},
17     {ATSClientFileTypes.ClientConfig, "network"},
18     {ATSClientFileTypes.ClientBootKernel, "vmlinuz"},
19     };
20     }
21    
22     public static string GetClientFileByType(ATSClientFileTypes type)
23     {
24     string file = string.Empty;
25     if (type == ATSClientFileTypes.ClientUnknown)
26     {
27     Logging.ATSClientManagerLog.FatalFormat("ATSClientFilesCollection::detected a request for type: {0}", type.ToString());
28     return string.Empty;
29     }
30     if (collection.ContainsKey(type)) { file = collection[type]; }
31     else
32     {
33     Logging.ATSClientManagerLog.FatalFormat("ATSClientFilesCollection does not contain a client file for type: {0}", type.ToString());
34     file = string.Empty;
35     }
36     return file;
37     }
38     public static ATSClientFileTypes GetClientFileTypeByName(string name)
39     {
40     ATSClientFileTypes found = ATSClientFileTypes.ClientUnknown;
41     foreach (KeyValuePair<ATSClientFileTypes, string> t in collection) { if (t.Value.ToLower() == name.ToLower()) { found = t.Key; break; } }
42     if (found == ATSClientFileTypes.ClientUnknown) { Logging.ATSClientManagerLog.FatalFormat("ATSClientFilesCollection does not contain a client type for file: {0}", name); }
43     return found;
44     }
45 william 341
46     public static ATSClientFileList GetClientFilesInPath(DirectoryInfo path)
47     {
48     ATSClientFileList list = new ATSClientFileList();
49     List<IATSClientFile> client_files = new List<IATSClientFile>();
50     List<FileInfo> files = new List<FileInfo>(path.GetFiles());
51     foreach (var file in files)
52     {
53     ATSClientFileTypes type = GetClientFileTypeByName(file.Name);
54     client_files.Add(ATSClientFile.Create(type, file.FullName));
55     }
56     list = new ATSClientFileList(client_files);
57     return list;
58     }
59     public static ATSClientFileList GetClientFilesInPath(string path)
60     {
61     return GetClientFilesInPath(new DirectoryInfo(path));
62     }
63    
64 william 335 }
65     }

  ViewVC Help
Powered by ViewVC 1.1.22