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
  • 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 null if 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

      boolean hasAttribute(Resource.Attribute attribute)
      Answers whether this resource has the specified Resource.Attribute. Which attributes are supported depends on the operating system; on macOS and Linux they include the user permissions Resource.Attribute.READABLE, Resource.Attribute.WRITABLE and Resource.Attribute.EXECUTABLE.
      Parameters:
      attribute - the Resource.Attribute to check for.
      Returns:
      true if this resource has the specified attribute, false if it doesn't.
      Since:
      2.0
    • setAttributes

      void setAttributes(Resource.Attribute[] attributes) throws IOException
      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 be null
      Throws:
      NullPointerException - if attributes is null
      IOException - if the underlying file system is unable to set the specified attributes on this resource
      Since:
      2.0