f$ = CreateFile(path$, file$[, table])
file$ in the path specified by
path$. This is basically the same as calling OpenFile() with #MODE_WRITE
on the file and closing it so you'll essentially get an empty file. The difference
is that CreateFile() doesn't accept a single path argument containing both the
path and the file specification but two individual arguments specifying the
directory where to create the file and the name of the file to be created. It
also returns the path to the file just created. All this makes CreateFile()
suitable for use with Android's Storage Access Framework (SAF) and with MediaStore
on Android which both work a little differently than traditional path specifications.
See Working with Android URIs for details.
Note that in contrast to OpenFile(), CreateFile() will fail if the
file already exists, except on Android when using the SAF or MediaStore URIs. In
that case CreateFile() will never fail if the file already exists. Instead,
a counter like (1), (2)... will be appended to the filename. To find out the
real filename of the file just created use GetFileAttributes() and the
Name table tag.
Note that CreateFile() is very important on Android when using SAF or MediaStore
URIs because with those URIs files have to be created first before you can write to them,
e.g. when saving a brush to a file using SAF or MediaStore you can't just go ahead
and call SaveBrush() but you first have to create the file using CreateFile()
and then you can call SaveBrush() on the newly created file. See Working with Android URIs for details.
Just like FullPath(), CreateFile() also supports the following special constants
on Android if you need to compose a MediaStore URI:
#MEDIA_DOWNLOADS
#MEDIA_IMAGES
#MEDIA_VIDEOS
#MEDIA_MUSIC
When passing one of these special constants, file$ may contain a single
subdirectory which is separated from the actual file using a single slash,
e.g. "subdir/file", to refer to a file in a MediaStore subdirectory.
Keep in mind, though, that only one nesting level is allowed so there must
not be more than one subdirectory in file$. See Working with Android URIs for details.
CreateFile() also accepts an optional table argument which can be used to
pass additional parameters. The following table elements are currently recognized:
Adapter:
UserTags:
MIMEType: