NFS emulation: what is the difference between fetch() and open()

What is the purpose of the MutableData NFS emulation fetch() and how does it differ from open()?

EDIT: I’ve partly answered my own question…

fetch() gets an NFS file object if it exists, while create() is used to get one for a new file.

After that, you can use open() etc.

So my remaining question is can fetch() be used and then allow access to file metadata?

1 Like

@happybeing, so as you’ve seen. fetch simply returns the File object. whereas open can be used to open and modify a file (using the openMode argument):

CONSTANTS.NFS_FILE_MODE_OVERWRITE: Replaces the entire content of the file when writing data.

CONSTANTS.NFS_FILE_MODE_APPEND: Appends to existing data in the file.

CONSTANTS.NFS_FILE_MODE_READ: Open file to read.

can fetch() be used and then allow access to file metadata?

Yup, so fetch() should return a File object: Home - Documentation

Such that you could do:

// myfile is a previously fetched File object.

console.log( myfile.modified ); // date <myfile> was modified in UTC

3 Likes