Package com.deltawalker.script
Interface Resource
public interface Resource
A file or folder taking part in a folder comparison, on a local disk or on a
remote server such as an FTP server. Returned by
DeltaNode.resource(Role).
const res = node.resource(Role.ONE);
if (res) {
console.log(res.getPath() + ': ' + res.getSize() + ' bytes, modified '
+ new Date(res.getLastModifiedTime()));
}
- Since:
- 2.0
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionReturns the attributes of this resource.longReturns the time this resource was last modified.getName()Returns the name of this resource, without its folder path.Returns the folder that contains this resource.getPath()Returns the path of this resource.longgetSize()Returns the size of this resource, in bytes.booleanhasAttribute(Resource.Attribute attribute) Answers whether this resource has the specifiedResource.Attribute.voidsetAttributes(Resource.Attribute[] attributes) Sets the attributes of this resource on disk.
-
Method Details
-
getAttributes
Resource.Attribute[] getAttributes()Returns the attributes of this resource. Which attributes are supported depends on the operating system.- Returns:
- an array with this resource's attributes
- Since:
- 2.0
-
getLastModifiedTime
long getLastModifiedTime()Returns the time this resource was last modified.- Returns:
- A number representing the time the resource was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970).
- Since:
- 2.0
-
getName
String getName()Returns the name of this resource, without its folder path.- Returns:
- the name of this resource
- Since:
- 2.0
-
getParent
Resource getParent()Returns the folder that contains this resource.- Returns:
- the parent of this resource, or
nullif this is a root such as '/' on macOS and Linux or "C:\" on Windows - Since:
- 2.0
-
getPath
String getPath()Returns the path of this resource.- Returns:
- the path of this resource
- Since:
- 2.0
-
getSize
long getSize()Returns the size of this resource, in bytes. For a folder, the size is the total size of the resources it contains.- Returns:
- the size in bytes.
- Since:
- 2.0
-
hasAttribute
Answers whether this resource has the specifiedResource.Attribute. Which attributes are supported depends on the operating system; on macOS and Linux they include the user permissionsResource.Attribute.READABLE,Resource.Attribute.WRITABLEandResource.Attribute.EXECUTABLE.- Parameters:
attribute- theResource.Attributeto check for.- Returns:
trueif this resource has the specified attribute,falseif it doesn't.- Since:
- 2.0
-
setAttributes
Sets the attributes of this resource on disk. Which attributes are supported depends on the operating system.- Parameters:
attributes- the attributes to set; can be empty, but cannot benull- Throws:
NullPointerException- ifattributesisnullIOException- if the underlying file system is unable to set the specifiedattributeson this resource- Since:
- 2.0
-