AppDirGet Method (CLIENT)


PLB Web Only, 9.9B

 

The AppDirGet method retrieves file and directory information from a path on a mobile device where the 'Plbwebcli' client is executing. This method starts an asynchronous operation to retrieve the file and directory information for a path on the mobile device. When the asynchronous operation is completed on the mobile device, a CLIENT object event named 'AppEventDirGet' is generated with the event data being returned as a JSON string found in ARG1. The method uses the following format:

 

[label]

{object}.AppDirGet

[GIVING {return}] USING [*Path=](path}][:

 

 

[*Options=]{flags{]]

 

Where:

label

Optional. A Program Execution Label.

object

Required. A CLIENT object.

return

Optional. A Numeric Variable that returns the success or failure of the method.

path

Required. A Character String Variable or string literal that specifies the path used to retrieve the information from the 'Plbwebcli' App persistent or temporary storage.

flags
Optional. A Numeric Variable or decimal number that specifies a bit mask value that controls the behaviors of this method.

Flags Affected: OVER, ZERO

Note the following:

  1. This method uses the Cordova plugin described as follows:
     

  2. https://www.npmjs.com/package/cordova-plugin-file

     

  3. The ZERO flag is always set when the {return} value is zero which indicates that the method execution was successful. The ZERO flag is clear if the {return} value is not zero which indicates that the method execution failed.

  4. The OVER flag is set if the {return} variable is too small to receive the numeric result.

  5. The {path} is required and it specifies the path being added to the 'Plbwebcli' APP persistent\temporary storage. A {path} has one of the following formats:

  6. Persistent Storage Path
    "cdvfile://localhost/persistent/{dir}"

     

    Temporary Storage Path
    "cdvfile://localhost/temporary/{dir}"
     
  7. The {options} bitmask value allows for special method behaviors to be used. The {options} bitmask values are described as follows:

  8.  

    Value

    Meaning

    0

    Default returns all information for the files and directories found in the path.

    1

    Returns all the information including meta data for the files and directories.

     

  9. The {return} value returns the numeric result of 0 when the method successfully started the asynchronous creation operation. The {return} value is returned as a non-zero value when the method failed to start the asynchronous creation operation. The {return} values are defined as follows:
     

  10. Value

    Meaning

    0

    Asynchronous creation started successfully.

    1

    Cordova App support not provided by client.

    2

    Cordova App extended error. See the CLIENT object 'AppExtendedError' to retrieve the extended error information.

    11

    Invalid path specified.

     

  11. This method starts a path asynchronous creation operation on the mobile device. The EVENTREG instruction must be used to register the 'AppEventDirAdd' event. When this event occurs, the path recreation operation result is stored as a JSON string in ARG1.

  12.  

    AppEventDirDel EQU 129

     

    If the 'AppDirDel' method encounters an error on the mobile device, the ARG1 result contains a JSON error string reported by the FileSystem API as follows:

     

    { "code": nnn }

     

    Where 'nnn' is an error code from the 'cordova-plugin-file' described as follows:

     

    Code Constant

    Description

    1

    NOT_FOUND_ERR

    2

    SECURITY_ERR

    3

    ABORT_ERR

    4

    NOT_READABLE_ERR

    5

    ENCODING_ERR

    6

    NO_MODIFICATION_ALLOWED_ERR

    7

    INVALID_STATE_ERR

    8

    SYNTAX_ERR

    9

    INVALID_MODIFICATION_ERR

    10

    QUOTA_EXCEEDED_ERR

    11

    TYPE_MISMATCH_ERR

    12

    PATH_EXISTS_ERR

     

    If the 'AppDirGet' method creation operation executes successfully on the mobile device, the event data is returned in ARG1 as a JSON string that contains fields reported by the FileSystem API as follows:

     

    {

      "isFile": <false|true>,

      "isDirectory": <false|true>,

      "name": "<name>",

      "fullPath": "<fullpath>",

      "filesystem": "<FileSystem: persistent>",

      "nativeURL": "ms-appdata:///local/dir/",

      "meta": {

       "modificationTime": "<timestamp>",

      "size": <size>

    }

     

    Where as:

    isFile
    'true' if the path item is a file.
    isDirectory
    'true' if the path item is a directory.
    name
    The name of the path (i.e., dir) used to retrieve the file and directory information.
    fullPath
    The full path name of the file or directory relative to the root.
    filesystem
    This indicates whether the path file\directory item was in 'persistent' or 'temporary' storage.
    nativeURL
    The native URL of the path file or directory item given in the true mobile device OS format.
    meta
    The meta information if the {options} bitmask contains a 1. This JSON object contains the fields:

    modificationTime - The last modification time.

     

    size - The size of the file in bytes.

    Example of CLIENT 'AppDirGet':

     

     

     

    EventReg

    Client, AppEventDirGet, GetDataDel, ARG1=DirData

     

    Client.AppDirGet

    Using "cdvfile://localhost/persistent/sds",1

     

     

    Failure Event Result in ARG1:

     

    {

         "code": 1

    }

     

    Successful Event Result in ARG1:

     

    {

         "isFile": false,

         "isDirectory": true,

         "name": "sds",

          "fullPath": "/sds",

         "filesystem": "<FileSystem: persistent>",

         "nativeURL": "ms-appdata:///local/sds"

         "meta":{

               "modificationTime": "2017-06-22T15:24:21.000Z",

               "size": 0

         }

    }

 

 

See Also: CLIENT, Client Methods, Method Syntax



PL/B Language Reference AppDirDel Method (CLIENT) AppDownload Method (CLIENT)