Make FilePathComponents internal, temporary disable tests of internal API

This commit is contained in:
Ilya Gorbunov
2016-01-19 21:13:08 +03:00
parent c1ad82ff8c
commit e9c14a02d3
2 changed files with 13 additions and 25 deletions
@@ -62,16 +62,14 @@ private fun String.getRootLength(): Int {
*
* @return string representing the root for this file, or empty string is this file name is relative.
*/
@Deprecated("This property has unclear semantics and will become internal soon.")
public val File.rootName: String
internal val File.rootName: String
get() = path.substring(0, path.getRootLength())
/**
* Returns root component of this abstract name, like / from /home/user, or C:\ from C:\file.tmp,
* or //my.host/home for //my.host/home/user
*/
@Deprecated("This property has unclear semantics and will become internal soon.")
public val File.root: File
internal val File.root: File
get() = File(rootName)
/**
@@ -89,16 +87,9 @@ public val File.isRooted: Boolean
* @property segments the list of [File] objects representing every directory in the path to the file,
* up to an including the file itself.
*/
@Deprecated("FilePathComponents has unclear semantics and will become internal soon.")
public data class FilePathComponents
internal data class FilePathComponents
internal constructor(public val root: File, public val segments: List<File>) {
@Deprecated("This constructor will be removed soon. Use File.toComponents() extension to create an instance of FilePathComponents.")
constructor (rootName: String, fileList: List<File>): this(File(rootName), fileList)
@Deprecated("Use 'segments' property instead.", ReplaceWith("segments"))
public val fileList: List<File> get() = segments
/**
* Returns a string representing the root for this file, or an empty string is this file name is relative.
*/
@@ -114,9 +105,6 @@ public data class FilePathComponents
*/
public val size: Int get() = segments.size
@Deprecated("Use 'size' property instead.", ReplaceWith("size"))
public fun size(): Int = size
/**
* Returns a sub-path of the path, starting with the directory at the specified [beginIndex] and up
* to the specified [endIndex].
@@ -142,9 +130,6 @@ internal fun File.toComponents(): FilePathComponents {
return FilePathComponents(File(rootName), list)
}
@Deprecated("FilePathComponents has unclear semantics and will become internal soon.")
public fun File.filePathComponents(): FilePathComponents = toComponents()
/**
* Returns a relative pathname which is a subsequence of this pathname,
* beginning from component [beginIndex], inclusive,
@@ -155,5 +140,4 @@ public fun File.filePathComponents(): FilePathComponents = toComponents()
* or [endIndex] is greater than existing number of components,
* or [beginIndex] is greater than [endIndex].
*/
@Deprecated("This function can fail since path segment count isn't known in advance.")
public fun File.subPath(beginIndex: Int, endIndex: Int): File = toComponents().subPath(beginIndex, endIndex)
internal fun File.subPath(beginIndex: Int, endIndex: Int): File = toComponents().subPath(beginIndex, endIndex)
+9 -5
View File
@@ -182,9 +182,10 @@ class FilesTest {
assertEquals(File("../../test"), File("test").relativeTo(File("dir/dir")))
}
/*
private fun checkFilePathComponents(f: File, root: File, elements: List<String>) {
assertEquals(root, f.root)
val components = f.filePathComponents()
val components = f.toComponents()
assertEquals(root, components.root)
assertEquals(elements, components.segments.map { it.toString() })
}
@@ -209,25 +210,26 @@ class FilesTest {
checkFilePathComponents(File("."), File(""), listOf("."))
checkFilePathComponents(File(".."), File(""), listOf(".."))
}
*/
@test fun fileRoot() {
val rooted = File("/foo/bar")
assertTrue(rooted.isRooted)
assertEquals("/", rooted.root.invariantSeparatorsPath)
// assertEquals("/", rooted.root.invariantSeparatorsPath)
if (isBackslashSeparator) {
val diskRooted = File("""C:\foo\bar""")
assertTrue(rooted.isRooted)
assertEquals("""C:\""", diskRooted.rootName)
// assertEquals("""C:\""", diskRooted.rootName)
val networkRooted = File("""\\network\share\""")
assertTrue(networkRooted.isRooted)
assertEquals("""\\network\share""", networkRooted.rootName)
// assertEquals("""\\network\share""", networkRooted.rootName)
}
val relative = File("foo/bar")
assertFalse(relative.isRooted)
assertEquals("", relative.rootName)
// assertEquals("", relative.rootName)
}
@test fun startsWith() {
@@ -273,6 +275,7 @@ class FilesTest {
}
}
/*
@test fun subPath() {
if (isBackslashSeparator) {
// Check only in Windows
@@ -283,6 +286,7 @@ class FilesTest {
assertEquals(File("foo"), File("/foo/bar/gav/hi").subPath(0, 1))
assertEquals(File("gav/hi"), File("/foo/bar/gav/hi").subPath(2, 4))
}
*/
@test fun normalize() {
assertEquals(File("/foo/bar/baaz"), File("/foo/./bar/gav/../baaz").normalize())