Ejemplo n.º 1
0
        public override void Execute(SharedObjects shared)
        {
            string fileName         = PopValueAssert(shared, true).ToString();
            string expressionResult = PopValueAssert(shared).ToString();

            AssertArgBottomAndConsume(shared);

            if (shared.VolumeMgr != null)
            {
                Volume volume = shared.VolumeMgr.CurrentVolume;
                if (volume != null)
                {
                    VolumeFile volumeFile = volume.OpenOrCreate(fileName);

                    if (volumeFile == null || !volumeFile.WriteLn(expressionResult))
                    {
                        throw new KOSFileException("Can't append to file: not enough space or access forbidden");
                    }
                }
                else
                {
                    throw new KOSFileException("Volume not found");
                }
            }
        }
Ejemplo n.º 2
0
        public override void Execute(SharedObjects shared)
        {
            string pathString = PopValueAssert(shared, true).ToString();
            string toAppend   = PopValueAssert(shared).ToString();

            AssertArgBottomAndConsume(shared);

            if (shared.VolumeMgr != null)
            {
                GlobalPath path   = shared.VolumeMgr.GlobalPathFromObject(pathString);
                Volume     volume = shared.VolumeMgr.GetVolumeFromPath(path);

                VolumeItem volumeItem = volume.Open(path) as VolumeFile;
                VolumeFile volumeFile = null;

                if (volumeItem == null)
                {
                    volumeFile = volume.CreateFile(path);
                }
                else if (volumeItem is VolumeDirectory)
                {
                    throw new KOSFileException("Can't append to file: path points to a directory");
                }
                else
                {
                    volumeFile = volumeItem as VolumeFile;
                }

                if (!volumeFile.WriteLn(toAppend))
                {
                    throw new KOSFileException("Can't append to file: not enough space or access forbidden");
                }
            }
        }