Beispiel #1
0
        public override FileContent ReadAll()
        {
            byte[] bytes = File.ReadAllBytes(fileInfo.FullName);

            bytes = CliVolume.ConvertFromWindowsNewlines(bytes);

            return(new FileContent(bytes));
        }
Beispiel #2
0
        /// <summary>
        /// Creates a volume.
        /// </summary>
        /// <param name="directory">Root directory of the volume.</param>
        /// <param name="name">Name of the volume.</param>
        /// <returns>Created volume.</returns>
        private CliVolume CreateVolume(string directory, string outputDirectory, string name)
        {
            CliVolume result = _volumeManager.GetVolume(name) as CliVolume;

            if (result == null)
            {
                result = new CliVolume(directory, outputDirectory, name);
                _volumeManager.Add(result);
            }

            return(result);
        }
Beispiel #3
0
        public override bool Write(byte[] content)
        {
            if (!fileInfo.Exists)
            {
                throw new KOSFileException("File does not exist: " + fileInfo.Name);
            }

            byte[] bytes = CliVolume.ConvertToWindowsNewlines(content);
            using (FileStream stream = fileInfo.Open(FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
            {
                stream.Write(bytes, 0, bytes.Length);
                stream.Flush();
            }

            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// Adds input and output volumes to given scripts.
        /// </summary>
        /// <param name="scripts">Scripts to add volumes to.</param>
        /// <param name="input">Input path of the file or directory.</param>
        /// <param name="output">Output path of the file or directory.</param>
        /// <param name="volumeName">Name of the volume to load the scripts into.</param>
        /// <returns>List of loaded Kerboscripts.</returns>
        private List <Kerboscript> AddVolumesToScripts(List <Kerboscript> scripts, string input, string output, string volumeName = "")
        {
            if (scripts != null)
            {
                string inputPath  = Path.GetFullPath(input);
                string outputPath = Path.GetFullPath(output);

                if (File.Exists(inputPath) == true)
                {
                    inputPath  = Directory.GetParent(inputPath).FullName;
                    outputPath = Directory.GetParent(outputPath).FullName;
                }

                CliVolume volume = CreateVolume(inputPath, outputPath, volumeName);
                scripts.ForEach(ks => ks.Volume = volume);
            }

            return(scripts);
        }
 public CliVolumeDirectory(CliVolume volume, VolumePath path) : base(volume, path)
 {
     this.volume     = volume;
     this.volumePath = volume.GetArchivePath(path);
 }
Beispiel #6
0
 public CliVolumeFile(CliVolume volume, FileInfo fileInfo, VolumePath path)
     : base(volume, path)
 {
     this.fileInfo = fileInfo;
 }