Example #1
0
        internal void Scan()
        {
            Logger.Info($"Scanning for project related files in '{this.FilePath}'...");
            var origPathDepth = this.FilePath.Count((c) => Path.DirectorySeparatorChar == c || Path.AltDirectorySeparatorChar == c);

            foreach (var fpath in Directory.EnumerateFiles(this.FilePath, "*", SearchOption.AllDirectories))
            {
                var fname = Path.GetFileName(fpath);
                var ext   = Path.GetExtension(fpath);
                var depth = fpath.Count((c) => Path.DirectorySeparatorChar == c || Path.AltDirectorySeparatorChar == c);
                if (depth - origPathDepth == 1 && fname.Equals("$PBOPREFIX$"))
                {
                    Logger.Info($"\tLocated ArmAPath at '{fpath.Remove(0, this.FilePath.Length)}'.");
                    try
                    {
                        using (var reader = new StreamReader(fpath))
                        {
                            this._ArmAPath = reader.ReadToEnd();
                        }
                    }
                    catch (Exception ex)
                    {
                        Virtual.ShowOperationFailedMessageBox(ex);
                    }
                }
                else if (ValidFileExtensions.Any((s) => s.Equals(ext, StringComparison.InvariantCultureIgnoreCase)))
                {
                    this.AddFile(fpath.Remove(0, this.FilePath.Length));
                    Logger.Info($"\tAdded '{fpath.Remove(0, this.FilePath.Length)}' to project.");
                }
            }
        }
Example #2
0
 private void UpdateArmAPathFromFile(string path)
 {
     try
     {
         using (var reader = new StreamReader(path))
         {
             this._ArmAPath = reader.ReadToEnd();
         }
     }
     catch (Exception ex)
     {
         Virtual.ShowOperationFailedMessageBox(ex);
     }
 }
Example #3
0
 public bool Delete()
 {
     try
     {
         this.OwningProject.RemoveFile(this);
         File.Delete(this.FilePath);
         return(true);
     }
     catch (Exception ex)
     {
         Virtual.ShowOperationFailedMessageBox(ex);
         return(false);
     }
 }
Example #4
0
 public void MoveRelative(string v)
 {
     try
     {
         var newPath   = Path.Combine(this.OwningProject.FilePath, v);
         var directory = Path.GetDirectoryName(newPath);
         if (!Directory.Exists(directory))
         {
             Directory.CreateDirectory(directory);
         }
         File.Move(this.FilePath, newPath);
         this.ProjectRelativePath = v;
     }
     catch (Exception ex)
     {
         Virtual.ShowOperationFailedMessageBox(ex);
     }
 }