Package org.sikuli.basics
Class FileManager
- java.lang.Object
-
- org.sikuli.basics.FileManager
-
public class FileManager extends Object
INTERNAL USE: Support for accessing files and other ressources
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFileManager.FileFilter
-
Constructor Summary
Constructors Constructor Description FileManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanbuildJar(String targetJar, String[] jars, String[] files, String[] prefixs, org.sikuli.basics.FileManager.JarFileFilter filter)static booleancheckJarContent(String jarPath, String jarContent)static StringconvertStreamToString(InputStream is)static FilecreateTempDir()static FilecreateTempDir(String path)static FilecreateTempFile(String suffix)static FilecreateTempFile(String suffix, String path)static booleandeleteFileOrFolder(File fPath)static booleandeleteFileOrFolder(File fPath, FileManager.FileFilter filter)static booleandeleteFileOrFolder(String fpPath)static booleandeleteFileOrFolder(String fpPath, FileManager.FileFilter filter)static voiddeleteNotUsedImages(String bundle, Set<String> usedImages)static voiddeleteTempDir(String path)static StringdownloadURL(String url, String localPath)download a file at the given url to a local folderstatic StringdownloadURL(String url, String localPath, JFrame progress)static StringdownloadURL(URL url, String localPath)download a file at the given url to a local folderstatic StringdownloadURLtoString(String src)static StringdownloadURLtoString(URL uSrc)static StringdownloadURLtoString(URL uSrc, boolean silent)static booleanexists(String path)static StringgetAddress(String arg)static StringgetAltFilename(String filename)static StringgetJarName(Class cname)static StringgetJarPath(Class cname)static StringgetName(String filename)static intgetPort(String p)static ProxygetProxy()static InetAddressgetProxyAddress(String arg)static intgetProxyPort(String p)static intgetRandomInt()static URLgetURLForContentFromURL(URL uRes, String fName)static booleanisBundle(String dir)static booleanisFilenameDotted(String name)static intisUrlUseabel(String sURL)static intisUrlUseabel(URL aURL)static StringmakeFileList(File path, String prefix)static URLmakeJarURL(File fJar)static StringmakeScriptjar(List<String> options)static URLmakeURL(String fName)static URLmakeURL(String fName, String type)static URLmakeURL(URL path, String fName)static voidmkdir(String path)static Stringnormalize(String path)static StringnormalizeAbsolute(String filename)static booleanopenURL(String url)open the given url in the standard browserstatic booleanpackJar(String folderName, String jarName, String prefix)static booleanpathEquals(String path1, String path2)static StringreadFileToString(File fPath)static voidresetFolder(File fPath)static FileresolveImagePath(File scriptFile)Returns the directory that contains the images used by the ScriptRunner.static StringsaveImage(BufferedImage img, String sImage, String bundlePath)static StringsaveTimedImage(BufferedImage img)static StringsaveTimedImage(BufferedImage img, String path)static StringsaveTimedImage(BufferedImage img, String path, String name)static StringsaveTmpImage(BufferedImage img)static StringsaveTmpImage(BufferedImage img, String path)static booleansetProxy(String pName, String pPort)static Stringslashify(String path, Boolean isDirectory)static FilesmartCopy(String src, String dest)Copy a file *src* to the path *dest* and check if the file name conflicts.static voidtraverseFolder(File fPath, FileManager.FileFilter filter)static booleanunpackJar(String jarName, String folderName, boolean del, boolean strip, org.sikuli.basics.FileManager.JarFileFilter filter)unpack a jar file to a folderstatic booleanunzip(File fZip, File fTarget)static booleanunzip(String inpZip, String target)static StringunzipSKL(String fpSkl)static booleanwriteStringToFile(String text, File fPath)static booleanwriteStringToFile(String text, String path)static booleanxcopy(File fSrc, File fDest)static booleanxcopy(File fSrc, File fDest, FileManager.FileFilter filter)static voidxcopy(String src, String dest)static voidxcopy(String src, String dest, FileManager.FileFilter filter)
-
-
-
Method Detail
-
isUrlUseabel
public static int isUrlUseabel(String sURL)
-
isUrlUseabel
public static int isUrlUseabel(URL aURL)
-
getProxy
public static Proxy getProxy()
-
getProxyAddress
public static InetAddress getProxyAddress(String arg)
-
getProxyPort
public static int getProxyPort(String p)
-
downloadURL
public static String downloadURL(URL url, String localPath)
download a file at the given url to a local folder- Parameters:
url- a valid urllocalPath- the folder where the file should go (will be created if necessary)- Returns:
- the absolute path to the downloaded file or null on any error
-
downloadURL
public static String downloadURL(String url, String localPath)
download a file at the given url to a local folder- Parameters:
url- a string representing a valid urllocalPath- the folder where the file should go (will be created if necessary)- Returns:
- the absolute path to the downloaded file or null on any error
-
openURL
public static boolean openURL(String url)
open the given url in the standard browser- Parameters:
url- string representing a valid url- Returns:
- false on error, true otherwise
-
createTempDir
public static File createTempDir()
-
getRandomInt
public static int getRandomInt()
-
deleteTempDir
public static void deleteTempDir(String path)
-
deleteFileOrFolder
public static boolean deleteFileOrFolder(File fPath, FileManager.FileFilter filter)
-
deleteFileOrFolder
public static boolean deleteFileOrFolder(File fPath)
-
deleteFileOrFolder
public static boolean deleteFileOrFolder(String fpPath, FileManager.FileFilter filter)
-
deleteFileOrFolder
public static boolean deleteFileOrFolder(String fpPath)
-
resetFolder
public static void resetFolder(File fPath)
-
traverseFolder
public static void traverseFolder(File fPath, FileManager.FileFilter filter)
-
saveTmpImage
public static String saveTmpImage(BufferedImage img)
-
saveTmpImage
public static String saveTmpImage(BufferedImage img, String path)
-
saveTimedImage
public static String saveTimedImage(BufferedImage img)
-
saveTimedImage
public static String saveTimedImage(BufferedImage img, String path)
-
saveTimedImage
public static String saveTimedImage(BufferedImage img, String path, String name)
-
xcopy
public static boolean xcopy(File fSrc, File fDest, FileManager.FileFilter filter)
-
xcopy
public static void xcopy(String src, String dest) throws IOException
- Throws:
IOException
-
xcopy
public static void xcopy(String src, String dest, FileManager.FileFilter filter) throws IOException
- Throws:
IOException
-
smartCopy
public static File smartCopy(String src, String dest) throws IOException
Copy a file *src* to the path *dest* and check if the file name conflicts. If a file with the same name exists in that path, rename *src* to an alternative name.- Parameters:
src- source filedest- destination path- Returns:
- the destination file if ok, null otherwise
- Throws:
IOException- on failure
-
convertStreamToString
public static String convertStreamToString(InputStream is)
-
exists
public static boolean exists(String path)
-
mkdir
public static void mkdir(String path)
-
isFilenameDotted
public static boolean isFilenameDotted(String name)
-
resolveImagePath
public static File resolveImagePath(File scriptFile)
Returns the directory that contains the images used by the ScriptRunner.- Parameters:
scriptFile- The file containing the script.- Returns:
- The directory containing the images.
-
getPort
public static int getPort(String p)
-
saveImage
public static String saveImage(BufferedImage img, String sImage, String bundlePath)
-
isBundle
public static boolean isBundle(String dir)
-
buildJar
public static boolean buildJar(String targetJar, String[] jars, String[] files, String[] prefixs, org.sikuli.basics.FileManager.JarFileFilter filter)
-
unpackJar
public static boolean unpackJar(String jarName, String folderName, boolean del, boolean strip, org.sikuli.basics.FileManager.JarFileFilter filter)
unpack a jar file to a folder- Parameters:
jarName- absolute path to jar filefolderName- absolute path to the target folderdel- true if the folder should be deleted before unpackstrip- true if the path should be strippedfilter- to select specific content- Returns:
- true if success, false otherwise
-
-