Class BambooFiles


  • public class BambooFiles
    extends Object
    Helper methods related to Files and Path classes.
    • Field Detail

      • log

        public static final org.apache.log4j.Logger log
    • Constructor Detail

      • BambooFiles

        public BambooFiles()
    • Method Detail

      • deleteQuietly

        public static boolean deleteQuietly​(Path path)
        Deletes a path quietly, returns true on success. If the path is a non-empty directory, it does not get deleted.
      • delete

        public static void delete​(Path path)
                           throws IOException
        Deletes files, including readonly files on Windows.
        Throws:
        IOException
      • deleteLogIfError

        public static void deleteLogIfError​(Path path,
                                            org.apache.log4j.Logger logger)
        Call delete(Path) and logs exception if happens.
      • setExecutable

        public static void setExecutable​(Path path,
                                         boolean isExecutable)
                                  throws IOException
        Sets executable bit on Path
        Throws:
        IOException
      • setAccessibleOnlyByOwner

        public static void setAccessibleOnlyByOwner​(@NotNull
                                                    @NotNull Path path)
                                             throws IOException
        Removes access to Path from non-owners. Note, for NTFS it removes all ACLs except owner. So if owner is not listed at ACLs then Path will become unavailable for Bamboo.
        Throws:
        IOException
      • resolvePathUnderParent

        public static Path resolvePathUnderParent​(@NotNull
                                                  @NotNull Path parent,
                                                  @NotNull
                                                  @NotNull String child)
        Fulfills the general contract of Path.resolve(String). The returned path is always in normalized and always rooted under the parent argument. Attempts to traverse out of the parent directory will result in IllegalArgumentException being thrown.
        Parameters:
        parent - parent directory
        child - child under parent directory. Relative paths are allowed as long as the result is under the parent directory
        Returns:
        a canonical child File rooted under parent directory