Esempio n. 1
0
		public /*internal*/ RAMOutputStream(RAMFile f)
		{
			file = f;
			
			// make sure that we switch to the
			// first needed buffer lazily
			currentBufferIndex = - 1;
			currentBuffer = null;
		}
Esempio n. 2
0
        public /*internal*/ RAMOutputStream(RAMFile f)
        {
            file = f;

            // make sure that we switch to the
            // first needed buffer lazily
            currentBufferIndex = -1;
            currentBuffer      = null;
        }
Esempio n. 3
0
		public /*internal*/ RAMInputStream(RAMFile f)
		{
			file = f;
			length = file.length;
			if (length / BUFFER_SIZE >= System.Int32.MaxValue)
			{
				throw new System.IO.IOException("Too large RAMFile! " + length);
			}
			
			// make sure that we switch to the
			// first needed buffer lazily
			currentBufferIndex = - 1;
			currentBuffer = null;
		}
Esempio n. 4
0
        public /*internal*/ RAMInputStream(RAMFile f)
        {
            file   = f;
            length = file.length;
            if (length / BUFFER_SIZE >= System.Int32.MaxValue)
            {
                throw new System.IO.IOException("Too large RAMFile! " + length);
            }

            // make sure that we switch to the
            // first needed buffer lazily
            currentBufferIndex = -1;
            currentBuffer      = null;
        }
Esempio n. 5
0
        /// <summary>Creates a new, empty file in the directory with the given name. Returns a stream writing this file. </summary>
        public override IndexOutput CreateOutput(System.String name)
        {
            EnsureOpen();
            RAMFile file = new RAMFile(this);

            lock (this)
            {
                RAMFile existing = (RAMFile)fileMap[name];
                if (existing != null)
                {
                    sizeInBytes       -= existing.sizeInBytes;
                    existing.directory = null;
                }
                fileMap[name] = file;
            }
            return(new RAMOutputStream(file));
        }
Esempio n. 6
0
 /// <summary>Removes an existing file in the directory.</summary>
 /// <throws>  IOException if the file does not exist </throws>
 public override void  DeleteFile(System.String name)
 {
     lock (this)
     {
         EnsureOpen();
         RAMFile file = (RAMFile)fileMap[name];
         if (file != null)
         {
             fileMap.Remove(name);
             file.directory = null;
             sizeInBytes   -= file.sizeInBytes;
         }
         else
         {
             throw new System.IO.FileNotFoundException(name);
         }
     }
 }
Esempio n. 7
0
 public override void  RenameFile(System.String from, System.String to)
 {
     lock (this)
     {
         EnsureOpen();
         RAMFile fromFile = (RAMFile)fileMap[from];
         if (fromFile == null)
         {
             throw new System.IO.FileNotFoundException(from);
         }
         RAMFile toFile = (RAMFile)fileMap[to];
         if (toFile != null)
         {
             sizeInBytes     -= toFile.sizeInBytes;                 // updates to RAMFile.sizeInBytes synchronized on directory
             toFile.directory = null;
         }
         fileMap.Remove(from);
         fileMap[to] = fromFile;
     }
 }
Esempio n. 8
0
		/// <summary>Creates a new, empty file in the directory with the given name. Returns a stream writing this file. </summary>
		public override IndexOutput CreateOutput(System.String name)
		{
			EnsureOpen();
			RAMFile file = new RAMFile(this);
			lock (this)
			{
				RAMFile existing = (RAMFile) fileMap[name];
				if (existing != null)
				{
					sizeInBytes -= existing.sizeInBytes;
					existing.directory = null;
				}
				fileMap[name] = file;
			}
			return new RAMOutputStream(file);
		}