Class ScriptfileUtils
- java.lang.Object
-
- com.dtolabs.rundeck.core.execution.script.ScriptfileUtils
-
public class ScriptfileUtils extends java.lang.ObjectUtility methods for writing temp files for scripts and setting file permissions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classScriptfileUtils.LineEndingStyleLine ending style
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSHOULD_ADD_BOM
-
Constructor Summary
Constructors Constructor Description ScriptfileUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.io.FilecreateTempFile(Framework framework)Deprecated.static java.io.FilecreateTempFile(IFramework framework)Creates a temp file and marks it for deleteOnExit, to clean up proactively callreleaseTempFile(java.io.File)with the result when completestatic ScriptfileUtils.LineEndingStylelineEndingStyleForNode(INodeEntry node)static booleanreleaseTempFile(java.io.File file)Remove a file that may have been created bycreateTempFile(com.dtolabs.rundeck.core.common.Framework).static voidsetExecutePermissions(java.io.File scriptfile)Set the executable flag on a file if supported by the OSstatic booleanshouldAddBomForNode(INodeEntry node)static voidwriteScriptFile(java.io.InputStream stream, java.lang.String scriptString, java.io.Reader reader, ScriptfileUtils.LineEndingStyle style, java.io.File scriptfile)Write script content to a destination file from one of the sourcesstatic voidwriteScriptFile(java.io.InputStream stream, java.lang.String scriptString, java.io.Reader reader, ScriptfileUtils.LineEndingStyle style, java.io.File scriptfile, boolean addBom)Write script content to a destination file from one of the sourcesstatic voidwriteScriptFile(java.io.InputStream stream, java.lang.String scriptString, java.io.Reader reader, ScriptfileUtils.LineEndingStyle style, java.io.File scriptfile, boolean addBom, FileCopierUtil.ContentModifier modifier)Write script content to a destination file from one of the sourcesstatic java.io.FilewriteScriptTempfile(Framework framework, java.io.InputStream stream, java.lang.String source, java.io.Reader reader, ScriptfileUtils.LineEndingStyle style)Copy a source stream or string content to a tempfile for script executionstatic java.io.FilewriteScriptTempfile(Framework framework, java.io.Reader source, ScriptfileUtils.LineEndingStyle style)Copy reader content to a tempfile for script execution
-
-
-
Field Detail
-
SHOULD_ADD_BOM
public static final java.lang.String SHOULD_ADD_BOM
- See Also:
- Constant Field Values
-
-
Method Detail
-
lineEndingStyleForNode
public static ScriptfileUtils.LineEndingStyle lineEndingStyleForNode(INodeEntry node)
- Parameters:
node- node- Returns:
- the line ending style for the node, based on the osFamily, or use LOCAL if undetermined
-
shouldAddBomForNode
public static boolean shouldAddBomForNode(INodeEntry node)
-
writeScriptTempfile
public static java.io.File writeScriptTempfile(Framework framework, java.io.Reader source, ScriptfileUtils.LineEndingStyle style) throws java.io.IOException
Copy reader content to a tempfile for script execution- Parameters:
framework- frameworksource- string contentstyle- style- Returns:
- tempfile
- Throws:
java.io.IOException- if an error occurs
-
writeScriptTempfile
public static java.io.File writeScriptTempfile(Framework framework, java.io.InputStream stream, java.lang.String source, java.io.Reader reader, ScriptfileUtils.LineEndingStyle style) throws java.io.IOException
Copy a source stream or string content to a tempfile for script execution- Parameters:
framework- frameworkstream- source streamsource- contentstyle- file line ending style to usereader- reader- Returns:
- tempfile
- Throws:
java.io.IOException- if an error occurs
-
writeScriptFile
public static void writeScriptFile(java.io.InputStream stream, java.lang.String scriptString, java.io.Reader reader, ScriptfileUtils.LineEndingStyle style, java.io.File scriptfile, boolean addBom) throws java.io.IOExceptionWrite script content to a destination file from one of the sources- Parameters:
stream- stream sourcescriptString- script contentreader- reader sourcestyle- line ending stylescriptfile- destination file- Throws:
java.io.IOException- on io error
-
writeScriptFile
public static void writeScriptFile(java.io.InputStream stream, java.lang.String scriptString, java.io.Reader reader, ScriptfileUtils.LineEndingStyle style, java.io.File scriptfile, boolean addBom, FileCopierUtil.ContentModifier modifier) throws java.io.IOExceptionWrite script content to a destination file from one of the sources- Parameters:
stream- stream sourcescriptString- script contentreader- reader sourcestyle- line ending stylescriptfile- destination file- Throws:
java.io.IOException- on io error
-
writeScriptFile
public static void writeScriptFile(java.io.InputStream stream, java.lang.String scriptString, java.io.Reader reader, ScriptfileUtils.LineEndingStyle style, java.io.File scriptfile) throws java.io.IOExceptionWrite script content to a destination file from one of the sources- Parameters:
stream- stream sourcescriptString- script contentreader- reader sourcestyle- line ending stylescriptfile- destination file- Throws:
java.io.IOException- on io error
-
createTempFile
@Deprecated public static java.io.File createTempFile(Framework framework) throws java.io.IOException
Deprecated.Creates a temp file and marks it for deleteOnExit, to clean up proactively callreleaseTempFile(java.io.File)with the result when complete- Parameters:
framework- fwk- Returns:
- Create a temp file in the framework
- Throws:
java.io.IOException- on io error
-
createTempFile
public static java.io.File createTempFile(IFramework framework) throws java.io.IOException
Creates a temp file and marks it for deleteOnExit, to clean up proactively callreleaseTempFile(java.io.File)with the result when complete- Parameters:
framework- fwk- Returns:
- Create a temp file in the framework
- Throws:
java.io.IOException- on io error
-
releaseTempFile
public static boolean releaseTempFile(java.io.File file)
Remove a file that may have been created bycreateTempFile(com.dtolabs.rundeck.core.common.Framework). If the file was not created that way, it will not be deleted.- Parameters:
file- a temp file created withcreateTempFile(com.dtolabs.rundeck.core.common.Framework)- Returns:
- true if the temp file was known and was deleted
-
setExecutePermissions
public static void setExecutePermissions(java.io.File scriptfile) throws java.io.IOExceptionSet the executable flag on a file if supported by the OS- Parameters:
scriptfile- target file- Throws:
java.io.IOException- if an error occurs
-
-