kOS.Safe.Persistence.Volume.Open C# (CSharp) Method

Open() public abstract method

Get a file given its name
public abstract Open ( VolumePath path, bool ksmDefault = false ) : VolumeItem
path VolumePath
ksmDefault bool in the scenario where there is no filename extension, do we prefer the .ksm over the .ks? The default is to prefer .ks
return VolumeItem
        public abstract VolumeItem Open(VolumePath path, bool ksmDefault = false);

Same methods

Volume::Open ( string pathString, bool ksmDefault = false ) : VolumeItem

Usage Example

Example #1
0
        public bool Copy(GlobalPath sourcePath, GlobalPath destinationPath, bool verifyFreeSpace = true)
        {
            Volume sourceVolume      = GetVolumeFromPath(sourcePath);
            Volume destinationVolume = GetVolumeFromPath(destinationPath);

            VolumeItem source      = sourceVolume.Open(sourcePath);
            VolumeItem destination = destinationVolume.Open(destinationPath);

            if (source == null)
            {
                throw new KOSPersistenceException("Path does not exist: " + sourcePath);
            }

            if (source is VolumeDirectory)
            {
                if (destination is VolumeFile)
                {
                    throw new KOSPersistenceException("Can't copy directory into a file");
                }

                if (destination == null)
                {
                    destination = destinationVolume.CreateDirectory(destinationPath);
                }
                else if (!sourcePath.IsRoot)
                {
                    destinationPath = destinationPath.Combine(sourcePath.Name);
                    destination     = destinationVolume.OpenOrCreateDirectory(destinationPath);
                }

                if (destination == null)
                {
                    throw new KOSException("Path was expected to point to a directory: " + destinationPath);
                }

                return(CopyDirectory(sourcePath, destinationPath, verifyFreeSpace));
            }
            else
            {
                if (destination is VolumeFile || destination == null)
                {
                    Volume targetVolume = GetVolumeFromPath(destinationPath);
                    return(CopyFile(source as VolumeFile, destinationPath, targetVolume, verifyFreeSpace));
                }
                else
                {
                    return(CopyFileToDirectory(source as VolumeFile, destination as VolumeDirectory, verifyFreeSpace));
                }
            }
        }
All Usage Examples Of kOS.Safe.Persistence.Volume::Open