Interface IFile

  • All Known Subinterfaces:
    CachingFile
    All Known Implementing Classes:
    JarEntryFile, JrtIoFile

    public interface IFile
    An abstraction of path names similar to the Path. File may be obtained from a concrete file system or from VFSManager File.getPath() is os-independent. File.getPath() is absolute, do not store absolute paths in files. Instead, use MacroProcessor/QualifiedPath Path is not a global file identifier, see QualifiedPath Also it is an MPS abstraction around the IDEA platform file system com.intellij.openapi.vfs.VirtualFile. IDEA provides an intelligent caching mechanism which might boost up the file system traversal (comparing to the File). See also CachingFile IFile must be immutable we define it as a pathname abstraction. That means that we cannot rename the IFile, we can only rename something that lies at this pathname on disk. The IFile itself must not be touched in any way. Otherwise it is cumbersome. The alternative is to reconsider the IFile contract.
    • Method Detail

      • getFileSystem

        @Deprecated
        @NotNull
        FileSystem getFileSystem()
        Deprecated.
        Use getFS() instead Note the IFileSystem is per-protocol, in which it differs from FileSystem.
      • getName

        @NotNull
        String getName()
        Returns:
        simply the last name of the file (the furthest one)
      • getPath

        @NotNull
        String getPath()
        Returns a path of this file in a file system.
      • getParent

        @Nullable
        IFile getParent()
        Returns:
        null iff the instance is root and has no parent, the parent folder otherwise
      • isArchive

        @Deprecated
        boolean isArchive()
        Deprecated.
      • isInArchive

        boolean isInArchive()
        Returns:
        whether the underlying pathname points to an archive file or some of its contents
      • getBundleHome

        @Deprecated
        IFile getBundleHome()
        Deprecated.
        use getPath() and extract the path you need
        Returns:
        the jar or folder which contains this file
      • isDirectory

        boolean isDirectory()
      • isReadOnly

        boolean isReadOnly()
      • getDescendant

        @Deprecated
        @NotNull
        IFile getDescendant​(@NotNull
                            String suffix)
        Deprecated.
        use findChild() instead. The problem of findDescendant is that it's unclear, can we pass an empty string, string with path separators, string with archive separators
      • findChild

        @NotNull
        IFile findChild​(@NotNull
                        String name)
        Immediate child only. Empty name is forbidden. Neither path separators nor archive separators can't present in name
      • getChildren

        @Nullable
        List<IFile> getChildren()
        Returns:
        the children of this file in case when it is a folder, null iff it is a file and therefore has no children
      • addListener

        default void addListener​(@NotNull
                                 FileListener listener)
        Deprecated.
        move to CachingFile
      • lastModified

        long lastModified()
        fixme if it is the same as in java.io.File then we need to enforce it
      • exists

        boolean exists()
      • setTimeStamp

        boolean setTimeStamp​(long time)
      • createNewFile

        boolean createNewFile()
        creates a physical file
        Returns:
        whether it is a success
      • mkdirs

        boolean mkdirs()
      • delete

        boolean delete()
        FIXME document what happens if one deletes non-empty folder. IoFile seems to force deletion. Is it the contract?
        Returns:
        true if the deletion went with a success
      • rename

        boolean rename​(@NotNull
                       String newName)
        renames the file at which the instance of this IFile points (if it exists) the file stays under the same directory and changes its name to the newName
        Returns:
        true iff success // * @deprecated use move(IFile)
      • move

        boolean move​(@NotNull
                     IFile newParent)
        moves/renames the file at which the instance of this IFile points
        Returns:
        true iff success
      • isDescendant

        default boolean isDescendant​(IFile file)