dyne / restroom-mw

🛠 Easy REST API builder executing Zencode
https://restroom.dyne.org
GNU Affero General Public License v3.0
3 stars 11 forks source link

Given statement to generate a dictionary listing of files found in a directory #213

Closed jaromil closed 1 year ago

jaromil commented 1 year ago
Given I have a directory of files found in '/my/folder'

should create a ACK.folder dictionary (and CODEC.folder) filled with ls -l contents relative to FILES_DIR conf, ready for the Zenroom VM to process it.

The ACK.folder dictionary should contain typical information given by ls -l and that is easy to retrieve using nodejs, for instance date of creation, size and maybe permission and date of last modification too. Naming of objects inside dictionary can follow the naming of stat(2):

           struct stat {
               dev_t     st_dev;         /* ID of device containing file */
               ino_t     st_ino;         /* Inode number */
               mode_t    st_mode;        /* File type and mode */
               nlink_t   st_nlink;       /* Number of hard links */
               uid_t     st_uid;         /* User ID of owner */
               gid_t     st_gid;         /* Group ID of owner */
               dev_t     st_rdev;        /* Device ID (if special file) */
               off_t     st_size;        /* Total size, in bytes */
               blksize_t st_blksize;     /* Block size for filesystem I/O */
               blkcnt_t  st_blocks;      /* Number of 512B blocks allocated */            
albertolerda commented 1 year ago

Inside restroom with don't deal with CODEC, we can put the list of dictionaries (i.e. the list of struct stat) inside the data and, from the point of view of zenroom, it will be a string dictionary or a string array. If we want to read it in a more comprehensive way we will have to discuss it inside zenroom.

jaromil commented 1 year ago

spot on! how about adding a string dictionary to input and "injecting" the zenroom statement Given I have a 'string dictionary' named 'directory'

we can discuss the details this afternoon in a call

albertolerda commented 1 year ago

fixed in PR #220