.. java:import:: java.io BufferedReader .. java:import:: java.io File .. java:import:: java.io FileInputStream .. java:import:: java.io IOException .. java:import:: java.io InputStream .. java:import:: java.io InputStreamReader .. java:import:: java.io Reader .. java:import:: java.nio.file LinkOption .. java:import:: java.security MessageDigest .. java:import:: java.security NoSuchAlgorithmException .. java:import:: java.util Arrays .. java:import:: org.caosdb.server CaosDBException .. java:import:: org.caosdb.server CaosDBServer .. java:import:: org.caosdb.server FileSystem .. java:import:: org.caosdb.server ServerProperties .. java:import:: org.caosdb.server.database.exceptions TransactionException .. java:import:: org.caosdb.server.entity Message .. java:import:: org.eclipse.jetty.io RuntimeIOException FileUtils ========= .. java:package:: org.caosdb.server.utils :noindex: .. java:type:: public class FileUtils Fields ------ chownScript ^^^^^^^^^^^ .. java:field:: public static String chownScript :outertype: FileUtils Methods ------- createFolders ^^^^^^^^^^^^^ .. java:method:: public static Undoable createFolders(File folder) throws Message :outertype: FileUtils createSymlink ^^^^^^^^^^^^^ .. java:method:: public static File createSymlink(File link, File target) :outertype: FileUtils delete ^^^^^^ .. java:method:: public static Undoable delete(File file) throws IOException, CaosDBException, InterruptedException :outertype: FileUtils delete ^^^^^^ .. java:method:: public static Undoable delete(File file, boolean recursive) throws IOException, CaosDBException, InterruptedException :outertype: FileUtils Delete a file undoable. If file is a directory and 'recursive' is true the directory and all of its sub folders are deleted. If file is a directory and 'recursive' is false file is deleted unless it has sub folders. If file is an actual file (and not a directory) the file is deleted. Otherwise, nothing happens. :param file: :param recursive: :throws IOException: :throws InterruptedException: :throws CaosDBException: getChecksum ^^^^^^^^^^^ .. java:method:: public static String getChecksum(File file) :outertype: FileUtils Get the HEXed SHA-512 checksum of a file or a folder. The Checksum C of a folder f is calculated by (recursively): C(f) = C(C(f_name) + C(f_subfile_1) + ... + C(f_subfile_N)) while f_name is the (String) name of f and f_subfile_1 to f_subfile_N are the alphabetically ordered subfiles and subfolders of f. The alphabetical order is defined by UTF16. :param file: :return: SHA-512 Checksum getMimeType ^^^^^^^^^^^ .. java:method:: public static String getMimeType(File file) :outertype: FileUtils Guess the MIME type of a file. This is based on the unix program 'file --mime-type' and might not work on other systems. :param file: getSize ^^^^^^^ .. java:method:: public static Long getSize(File file) :outertype: FileUtils Get the size of a file or folder. :param file: isSubDirSymlinkSave ^^^^^^^^^^^^^^^^^^^ .. java:method:: public static boolean isSubDirSymlinkSave(File file, File root) :outertype: FileUtils Return true iff `file` is not a simlink to a directory and `root` is not a simlink. Symlinks are not allowed for the root. Symlinks are allowed only for a File object if it is a file symlink, not a directory symlink. :param file: :param root: :throws RuntimeException,: if subdir is symlink on a directory or if the root is a simlink. isSymlink ^^^^^^^^^ .. java:method:: public static boolean isSymlink(File file) :outertype: FileUtils isSymlinkPointingTo ^^^^^^^^^^^^^^^^^^^ .. java:method:: public static boolean isSymlinkPointingTo(File symlink, File target) :outertype: FileUtils :param symlink: :param target: :return: true, if symlink is a symbolic link and pointing to target. false otherwise rename ^^^^^^ .. java:method:: public static Undoable rename(File file, File target) throws Message, IOException :outertype: FileUtils runChownScript ^^^^^^^^^^^^^^ .. java:method:: public static void runChownScript(File file) :outertype: FileUtils testChownScript ^^^^^^^^^^^^^^^ .. java:method:: @Deprecated public static void testChownScript() throws IOException, InterruptedException, CaosDBException :outertype: FileUtils :throws IOException: :throws InterruptedException: :throws CaosDBException: toHex ^^^^^ .. java:method:: public static String toHex(byte[] binary) :outertype: FileUtils Convert a byte array to HEX :param b: :return: hexadecimal (as String). unlink ^^^^^^ .. java:method:: public static Undoable unlink(File file) throws IOException, InterruptedException :outertype: FileUtils