android - exclusive parameter when using GetFile with Phonegap -


i reading through documentation on phonegap , i'm struggling understand point of exclusive parameter when getting files.

so documentation lists example.

// create lock file, if , if doesn't exist. lockfile = datadir.getfile("lockfile.txt", {create: true, exclusive: true}); 

so i'm struggling head around surely create "lockfile.txt" if file doesn't exist anyway?

how setting exclusive parameter true make difference? when needed?

different object literals , differences

create false:

  • exclusive ignored.
  • if path exists file returned.
  • if path doesn't exist error thrown. error code 1 (not_found_err).
  • if path exists, it's directory error thrown. error code 11 (type_mismatch_err).

create true:

  • if exclusive true , path exists error thrown. error code 12 (path_exists_err).

  • if exclusive false no error when path exists. when path doesn't exist file created.

everything typed above visible in image below.

different object literals , differences

how setting exclusive parameter true make difference?

when create false not make difference. when create true , if file exists not overwritten , error. error code 12 (path_exists_err).

when needed?

maybe don't want file overwritten.

sources:

the image: https://developer.mozilla.org/en-us/docs/web/api/directoryentry

error codes: https://developer.mozilla.org/en-us/docs/web/api/fileerror


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -