Skip to content

Commit 740fa77

Browse files
committed
Remove deprecated FSProvider interfaces
All the docs except JVMFileSystemProvider.ReadOnly and JVMFileSystemProvider.ReadWrite are left untouched.
1 parent 3ba946a commit 740fa77

File tree

3 files changed

+84
-252
lines changed

3 files changed

+84
-252
lines changed

rag/rag-base/src/commonMain/kotlin/ai/koog/rag/base/files/FileSystemProvider.kt

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ import kotlinx.io.Source
88
* for interacting with a filesystem through file operations and content reading/writing.
99
*/
1010
public object FileSystemProvider {
11-
1211
/**
13-
* Handles serialization and deserialization of file paths.
12+
* Provides operations for path serialization, structure navigation, and content reading
13+
* in a read-only manner without modifying the filesystem.
1414
*/
15-
@Deprecated("For internal use only.")
16-
public interface Serialization<Path> {
17-
15+
public interface ReadOnly<Path> {
1816
/**
1917
* Converts a [path] to its absolute path string representation.
2018
* This method works with the path structure
@@ -67,15 +65,7 @@ public object FileSystemProvider {
6765
* @return The extension of [path] or empty string if [path] doesn't have an extension.
6866
*/
6967
public fun extension(path: Path): String
70-
}
7168

72-
/**
73-
* Provides operations for examining filesystem structure.
74-
*
75-
* @param Path The type representing file paths in the implementation.
76-
*/
77-
@Deprecated("For internal use only.")
78-
public interface Select<Path> : Serialization<Path> {
7969
/**
8070
* Retrieves metadata for a file or directory using a [path].
8171
*
@@ -125,15 +115,7 @@ public object FileSystemProvider {
125115
* @throws IOException if an I/O error occurs while checking [path] existence.
126116
*/
127117
public suspend fun exists(path: Path): Boolean
128-
}
129118

130-
/**
131-
* Provides operations for reading file content.
132-
*
133-
* @param Path The type representing file paths in the implementation.
134-
*/
135-
@Deprecated("For internal use only.")
136-
public interface Read<Path> : Serialization<Path> {
137119
/**
138120
* Reads the content of a file at the specified [path].
139121
*
@@ -167,22 +149,10 @@ public object FileSystemProvider {
167149
}
168150

169151
/**
170-
* Provides a read-only interface that combines the functionalities of [FileSystemProvider.Serialization], [FileSystemProvider.Select],
171-
* and [FileSystemProvider.Read].
172-
*
173-
* It provides operations for path serialization, structure navigation, and content reading
174-
* in a read-only manner without modifying the filesystem.
175-
*/
176-
public interface ReadOnly<Path> : Serialization<Path>, Select<Path>, Read<Path>
177-
178-
/**
179-
* Provides operations for creating, moving, writing, and deleting files or directories.
180-
*
181-
* This interface focuses on write operations and complements the read operations
182-
* provided by other interfaces.
152+
* This is the most comprehensive interface, offering complete filesystem operations
153+
* including reading, writing, and path manipulation.
183154
*/
184-
@Deprecated("For internal use only.")
185-
public interface Write<Path> : Serialization<Path> {
155+
public interface ReadWrite<Path> : ReadOnly<Path> {
186156
/**
187157
* Creates a new file or directory inside [parent] with specified [name] and [type].
188158
* Parent directories will be created if they don't exist.
@@ -242,12 +212,4 @@ public object FileSystemProvider {
242212
*/
243213
public suspend fun delete(parent: Path, name: String)
244214
}
245-
246-
/**
247-
* Provides a read-write interface that combines the functionalities of [FileSystemProvider.ReadOnly] and [FileSystemProvider.Write] for full filesystem access.
248-
*
249-
* This is the most comprehensive interface, offering complete filesystem operations
250-
* including reading, writing, and path manipulation.
251-
*/
252-
public interface ReadWrite<Path> : ReadOnly<Path>, Write<Path>
253215
}

rag/rag-base/src/jvmMain/kotlin/ai/koog/rag/base/files/JVMFileSystemProvider.kt

Lines changed: 7 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ import kotlin.use
4646
*/
4747
public object JVMFileSystemProvider {
4848
/**
49-
* Provides functionality for serializing and deserializing file paths and handling metadata related to file paths.
50-
* Implements the `FileSystemProvider.Serialization` interface for `Path` type.
49+
* Provides operations for path serialization, structure navigation, and content reading using [Path] objects
50+
* in a read-only manner without modifying the filesystem.
5151
*/
52-
public object Serialization : FileSystemProvider.Serialization<Path> {
52+
public object ReadOnly : FileSystemProvider.ReadOnly<Path> {
53+
5354
/**
5455
* Converts the given [path] to its absolute path representation as a string.
5556
* The path is normalized before being converted.
@@ -119,15 +120,7 @@ public object JVMFileSystemProvider {
119120
}
120121
return adjustedPath
121122
}
122-
}
123123

124-
/**
125-
* Object implementing file system operations and serialization for file paths.
126-
* Provides functionality for retrieving metadata, listing directory contents,
127-
* determining parent paths, checking the existence of paths, and computing relative paths.
128-
* Delegates serialization-related functionality to the `Serialization` interface.
129-
*/
130-
public object Select : FileSystemProvider.Select<Path>, FileSystemProvider.Serialization<Path> by Serialization {
131124
/**
132125
* Retrieves metadata for a given file or directory path.
133126
*
@@ -195,13 +188,7 @@ public object JVMFileSystemProvider {
195188
* @return `true` if the file or directory exists, `false` otherwise.
196189
*/
197190
override suspend fun exists(path: Path): Boolean = path.exists()
198-
}
199191

200-
/**
201-
* Provides utility methods for reading file data and retrieving file-related metadata.
202-
* Implements the `FileSystemProvider.Read` and delegates file serialization operations to the `Serialization` interface.
203-
*/
204-
public object Read : FileSystemProvider.Read<Path>, FileSystemProvider.Serialization<Path> by Serialization {
205192
/**
206193
* Reads the contents of the file located at the specified path.
207194
*
@@ -248,123 +235,10 @@ public object JVMFileSystemProvider {
248235
}
249236

250237
/**
251-
* A read-only object implementing file system provider interfaces for handling file
252-
* serialization, selection, and reading functionalities.
253-
*
254-
* This object combines the functionalities of `FileSystemProvider.ReadOnly`,
255-
* `FileSystemProvider.Select`, and `FileSystemProvider.Read` using delegation.
256-
* It provides operations for path serialization, structure navigation, and
257-
* content reading in a read-only manner.
258-
*/
259-
public object ReadOnly :
260-
FileSystemProvider.ReadOnly<Path>,
261-
FileSystemProvider.Select<Path> by Select,
262-
FileSystemProvider.Read<Path> by Read {
263-
264-
/**
265-
* Converts the given Path to its absolute path string representation.
266-
*
267-
* @param path the path to be converted to an absolute path string
268-
* @return the absolute path string representation of the given path
269-
*/
270-
override fun toAbsolutePathString(path: Path): String = Serialization.toAbsolutePathString(path)
271-
272-
/**
273-
* Converts an absolute string representation of a file path into a normalized Path object.
274-
*
275-
* @param path The absolute string representation of the file path to convert.
276-
* @return A normalized Path object corresponding to the given absolute string.
277-
*/
278-
override fun fromAbsoluteString(path: String): Path = Serialization.fromAbsoluteString(path)
279-
280-
/**
281-
* Resolves a given relative path string against a base path and returns the normalized path.
282-
*
283-
* @param base The base path to resolve the relative string against.
284-
* @param path The relative path string to be resolved.
285-
* @return The normalized absolute path obtained by resolving the relative path string against the base path.
286-
*/
287-
override fun fromRelativeString(base: Path, path: String): Path = Serialization.fromRelativeString(base, path)
288-
289-
/**
290-
* Retrieves the name of the given path.
291-
*
292-
* @param path the Path object from which the name will be extracted.
293-
* @return the name of the provided path as a String.
294-
*/
295-
override fun name(path: Path): String = Serialization.name(path)
296-
297-
/**
298-
* Retrieves the file extension from the specified path using the serialization logic.
299-
*
300-
* @param path The path from which to extract the file extension.
301-
* @return The file extension as a string.
302-
*/
303-
override fun extension(path: Path): String = Serialization.extension(path)
304-
}
305-
306-
/**
307-
* Provides a combined object interface for performing both read and write file system operations.
308-
*
309-
* `ReadWrite` implements the `FileSystemProvider.ReadWrite` interface, extending both
310-
* read-only and write capabilities. By delegating to `ReadOnly` and `Write` objects, it provides
311-
* comprehensive file system operations including reading, writing, serialization, and path manipulation.
312-
*/
313-
public object ReadWrite :
314-
FileSystemProvider.ReadWrite<Path>,
315-
FileSystemProvider.ReadOnly<Path> by ReadOnly,
316-
FileSystemProvider.Write<Path> by Write {
317-
318-
/**
319-
* Converts the specified [path] to its absolute path represented as a string.
320-
*
321-
* @param path the path to be converted into an absolute path string
322-
* @return the absolute path as a string
323-
*/
324-
override fun toAbsolutePathString(path: Path): String = Serialization.toAbsolutePathString(path)
325-
326-
/**
327-
* Converts an absolute string path into a normalized Path object suitable for the current file system.
328-
*
329-
* @param path The absolute string path to be converted.
330-
* @return A Path object representing the input absolute string, normalized for the current file system.
331-
*/
332-
override fun fromAbsoluteString(path: String): Path = Serialization.fromAbsoluteString(path)
333-
334-
/**
335-
* Resolves a relative path string against a given base path and normalizes the resulting path.
336-
*
337-
* @param base The base path against which the relative path string will be resolved.
338-
* @param path The relative path string to be resolved.
339-
* @return The resolved and normalized path as a `Path` object.
340-
*/
341-
override fun fromRelativeString(base: Path, path: String): Path = Serialization.fromRelativeString(base, path)
342-
343-
/**
344-
* Retrieves the name of the file or directory represented by the specified path.
345-
*
346-
* @param path the path from which the name should be extracted
347-
* @return the name of the file or directory as a string
348-
*/
349-
override fun name(path: Path): String = Serialization.name(path)
350-
351-
/**
352-
* Gets the extension of the file represented by the given path.
353-
*
354-
* @param path The path of the file whose extension is to be determined.
355-
* @return The file extension as a string.
356-
*/
357-
override fun extension(path: Path): String = Serialization.extension(path)
358-
}
359-
360-
/**
361-
* Singleton object that provides implementations for creating, moving, writing, and deleting files or directories,
362-
* while adhering to a serialization context. It also ensures compatibility with specific operating system constraints
363-
* such as Windows reserved names.
364-
* Implements the `FileSystemProvider.Write` interface with `Path` as the path type and delegates serialization functionalities
365-
* to a `Serialization` implementation.
238+
* This is the most comprehensive interface, offering complete filesystem operations using [Path] objects
239+
* including reading, writing, and path manipulation.
366240
*/
367-
public object Write : FileSystemProvider.Write<Path>, FileSystemProvider.Serialization<Path> by Serialization {
241+
public object ReadWrite : FileSystemProvider.ReadWrite<Path>, FileSystemProvider.ReadOnly<Path> by ReadOnly {
368242

369243
/**
370244
* Contains a set of reserved file names in Windows operating systems.

0 commit comments

Comments
 (0)