示例#1
0
 public void ReplaceSysAttrAll(string name, string oldValue, string newValue)
 {
     string[] files = System.IO.Directory.GetFiles(m_dataDir);
     foreach (string dataFile in files)
     {
         OSBLEFile of = GetFile(dataFile);
         if (of.ContainsSysAttr(name, oldValue))
         {
             of.SetSysAttr(name, newValue);
             of.SaveAttrs();
         }
     }
 }
示例#2
0
        private FileCollection GetFilesWithAttribute(string attrClass, string attrName, string attrValue)
        {
            if (!System.IO.Directory.Exists(DataFilesPath))
            {
                return(new AttributableFileCollection(DataFilesPath, AttrFilesPath,
                                                      new List <string>()));
            }

            // Compare everything in lower case except the value
            attrClass = attrClass.ToLower();
            attrName  = attrName.ToLower();

            string[]      dataFiles = System.IO.Directory.GetFiles(DataFilesPath);
            List <string> files     = new List <string>();

            foreach (string file in dataFiles)
            {
                // Get the name for the attribute file
                string attrFileName = AttributableFileCollection.GetAttrFileName(AttrFilesPath, file);
                if (string.IsNullOrEmpty(attrFileName) ||
                    !System.IO.File.Exists(attrFileName))
                {
                    continue;
                }

                OSBLEFile af = OSBLEFile.CreateFromExisting(file, attrFileName);

                if ("systemattributes" == attrClass)
                {
                    if (!af.ContainsSysAttr(attrName, attrValue))
                    {
                        continue;
                    }
                }
                else
                {
                    if (!af.ContainsUserAttr(attrName, attrValue))
                    {
                        continue;
                    }
                }

                files.Add(file);
            }
            return(new AttributableFileCollection(DataFilesPath, AttrFilesPath, files));
        }
示例#3
0
 public OSBLEFile GetFile(string fileName)
 {
     // If the file doesn't exist then we'll assume it's a relative path and
     // try combining it with the data files path.
     if (!System.IO.File.Exists(fileName))
     {
         fileName = Path.Combine(DataFilesPath, fileName);
         if (!System.IO.File.Exists(fileName))
         {
             return(null);
         }
     }
     return(OSBLEFile.CreateFromExisting(
                fileName,
                AttributableFileCollection.GetAttrFileName(
                    AttrFilesPath, Path.GetFileName(fileName))));
 }