Files and directories
The two parts of this group do different things at different times. file
packs a file from the build machine into the installer; everything else
moves, copies or deletes files on the target machine while the installer
runs. A path parameter takes forward slashes and normalises them on the way
out, but a path fragment stored in a variable does not, so write \ in those
(why).
Packs one or more files into the installer and unpacks them into the current
output directory. A missing file is a build error unless nonFatal says
otherwise.
Usage file(filespec, …[, { … }]) → nothing
Options recursive, exclude = { … }, keepAttributes, nonFatal,
allowSkip, overwrite, outName
keepAttributes is File /a, which only keeps anything when makensis runs on
Windows. Elsewhere makensis drops it, and the compiler silences the warning it
gives for that, so a build off Windows still passes -WX.
setOutPath(INSTDIR)file("assets/icon.ico", { exclude = { "*.tmp", "*.log" } })allowSkip is AllowSkipFiles for this one call: false takes the Ignore
button away when the target file is locked. overwrite is SetOverwrite for
this one call, "on", "off", "try", "ifnewer" or "ifdiff". NSIS’s
commands hold for every File after them in the script, so the compiler writes
them before this File and puts back the
allowSkipFiles and overwrite
attributes after it.
outName is /oname=: it unpacks the file under another name, relative to the
output directory unless it is a full path. It takes one filespec without a
wildcard, and neither recursive nor exclude.
setOutPath(INSTDIR)file("config.default.ini", { outName = "config.ini" })ReserveFile
Section titled “ReserveFile”Puts a file at the head of the data block, so it can be extracted before the
rest. Reserving a plugin is the compiler’s job and needs no code: it works
out which plugins .onInit can reach and writes ReserveFile /plugin itself.
Usage reserveFile(filespec, …[, { … }]) → nothing
Options nonFatal, recursive, exclude = { … }
SetOutPath
Section titled “SetOutPath”Sets the directory that following file calls unpack into, creating it if it
does not exist, and the working directory for shortcuts made afterwards.
Usage setOutPath(path) → nothing
setOutPath(INSTDIR)InitPluginsDir
Section titled “InitPluginsDir”Nothing to write and nothing to remember: any body that names PLUGINSDIR gets the
line at the top of it, because $PLUGINSDIR expands to nothing until something
creates it and NSIS never says so.
setOutPath(PLUGINSDIR) -- InitPluginsDir is written above thisfile("assets/splash.bmp")CreateDirectory
Section titled “CreateDirectory”Creates a directory and every missing parent. Unlike setOutPath it does not
change where later file calls land.
Usage createDirectory(directoryName) → nothing
createDirectory(INSTDIR .. "/logs")Delete
Section titled “Delete”Deletes a file, or every file matching a wildcard. Deleting something that is
not there is not an error — check with fileExists if you care.
Usage delete(filespec[, { … }]) → nothing
Options rebootOk
delete(INSTDIR .. "/old.txt", { rebootOk = true })Removes a directory. It must be empty unless recursive is set, and recursive
on a directory the user chose is how an uninstaller eats a disk.
Usage rmDir(directoryName[, { … }]) → nothing
Options recursive, rebootOk
rmDir(INSTDIR, { recursive = true, rebootOk = true })Rename
Section titled “Rename”Moves a file, across directories as well as within one. With rebootOk, a
rename blocked by a lock is queued for the next restart.
Usage rename(sourceFile, destinationFile[, { … }]) → nothing
Options rebootOk
rename(INSTDIR .. "/old.txt", INSTDIR .. "/new.txt")CopyFiles
Section titled “CopyFiles”Copies files already on the target disk, with the shell’s copy progress dialog.
For files coming out of the installer, use file.
Usage copyFiles(sourcePath, destinationPath[, sizeInKb[, { … }]]) → nothing
Options silent, filesOnly
copyFiles(INSTDIR .. "/data", INSTDIR .. "/backup")SetFileAttributes
Section titled “SetFileAttributes”Usage setFileAttributes(file, attribute) → nothing
setFileAttributes(INSTDIR .. "/config.ini", "READONLY")Asking the file system a question
Section titled “Asking the file system a question”| NSIS | Installua |
|---|---|
GetFullPathName |
getFullPathName(pathOrFile[, { … }]) → string |
GetTempFileName |
getTempFileName([baseDir]) → string |
SearchPath |
searchPath(filename) → string |
GetFileTime |
getFileTime(file) → int, int (high, low) |
GetFileTimeLocal |
getFileTimeLocal(localFile) → int, int — the build machine |
local temp = getTempFileName()detailPrint(temp)