cvsimport
[beagle.git] / beagled / Lucene.Net / Store / Directory.cs
blob10c9b758e3caec8d66a82973c320e938bc217598
1 /*
2 * Copyright 2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using System;
19 namespace Lucene.Net.Store
22 /// <summary>A Directory is a flat list of files. Files may be written once, when they
23 /// are created. Once a file is created it may only be opened for read, or
24 /// deleted. Random access is permitted both when reading and writing.
25 ///
26 /// <p> Java's i/o APIs not used directly, but rather all i/o is
27 /// through this API. This permits things such as: <ul>
28 /// <li> implementation of RAM-based indices;
29 /// <li> implementation indices stored in a database, via JDBC;
30 /// <li> implementation of an index as a single file;
31 /// </ul>
32 ///
33 /// </summary>
34 /// <author> Doug Cutting
35 /// </author>
36 public abstract class Directory
38 /// <summary>Returns an array of strings, one for each file in the directory. </summary>
39 public abstract System.String[] List();
41 /// <summary>Returns true iff a file with the given name exists. </summary>
42 public abstract bool FileExists(System.String name);
44 /// <summary>Returns the time the named file was last modified. </summary>
45 public abstract long FileModified(System.String name);
47 /// <summary>Set the modified time of an existing file to now. </summary>
48 public abstract void TouchFile(System.String name);
50 /// <summary>Removes an existing file in the directory. </summary>
51 public abstract void DeleteFile(System.String name);
53 /// <summary>Renames an existing file in the directory.
54 /// If a file already exists with the new name, then it is replaced.
55 /// This replacement should be atomic.
56 /// </summary>
57 public abstract void RenameFile(System.String from, System.String to);
59 /// <summary>Returns the length of a file in the directory. </summary>
60 public abstract long FileLength(System.String name);
62 /// <deprecated> use {@link #CreateOutput(String)}
63 /// </deprecated>
64 public virtual OutputStream createFile(System.String name)
66 return (OutputStream) CreateOutput(name);
69 /// <summary>Creates a new, empty file in the directory with the given name.
70 /// Returns a stream writing this file.
71 /// </summary>
72 public virtual IndexOutput CreateOutput(System.String name)
74 // default implementation for back compatibility
75 // this method should be abstract
76 return (IndexOutput) createFile(name);
79 /// <deprecated> use {@link #OpenInput(String)}
80 /// </deprecated>
81 public virtual InputStream OpenFile(System.String name)
83 return (InputStream) OpenInput(name);
86 /// <summary>Returns a stream reading an existing file. </summary>
87 public virtual IndexInput OpenInput(System.String name)
89 // default implementation for back compatibility
90 // this method should be abstract
91 return (IndexInput) OpenFile(name);
94 /// <summary>Construct a {@link Lock}.</summary>
95 /// <param name="name">the name of the lock file
96 /// </param>
97 public abstract Lock MakeLock(System.String name);
99 /// <summary>Closes the store. </summary>
100 public abstract void Close();