addResource ( file-path, resource-type, resource-id, binary-data [, resource-name ]) |
Returns: null | Location: FileLib | ||||||||||||
Given the full path to a resource file in file-path, the type in resource-type, and an ID in resource-id, this function creates a new resource whose value is binary-data. If the optional resource-name parameter is defined, the new resource will be named as specified. See Also: |
appendFile ( file-path, text ) |
Returns: null | Location: FileLib | ||||||
Appends the value of the text parameter to the end of a text file. This function is very useful for creating log files apart from WebSiphon's main log or exporting data in a format usable by other applications. Remember to include the appropriate number of tabs, carriage returns, etc. for formatting if necessary. The output file will be created if no file exists as specified by file-path. Example: my_log = template_path & "my log.log"; appendFile(my_log, "\rThis template was accessed. Yow!"); |
copyFile ( file-path, new-path ) |
Returns: null | Location: FileLib | ||||||
Copies the file whose full path is file-path to the new location specified by new-path. The new-path parameter may be a destination folder path or full file path. This function will only work with files, not folders. If you need to copy a folder, use copyFolder() instead. |
copyFolder ( folder-path, new-path ) |
Returns: null | Location: FileLib | ||||||
Copies the folder whose full path is folder-path to the new location specified by new-path. The new-path parameter must be a folder path, not a path to a file or an error will be returned. This function will only work with folders, not files. If you need to copy a file, use copyFile() instead. |
countResources ( file-path, resource-type ) |
Returns: integer | Location: FileLib | ||||||
Given the full path to a resource file in file-path and the resource type in resource-type, this function returns the number of resources of the specified type that exist. |
fileExists ( file-path ) |
Returns: boolean | Location: FileLib | ||||
Given the full path file-path, a boolean will be returned indicating whether the file actually exists or not. Examples:
|
folderExists ( folder-path ) |
Returns: boolean | Location: FileLib | ||||
Given the full path folder-path, a boolean will be returned indicating whether the folder actually exists or not. Example: if folderExists("Hard Drive:System Folder:") then print "true"; else print "false"; end if; >> true |
getCreationDate ( file-path ) |
Returns: string | Location: FileLib | ||||
Given the full path file-path, the file's creation date and time will be returned as a string containing both parts in short form. This string is suitable for passing to the date and time functions. |
getFileComments ( file-path ) |
Returns: string | Location: FileLib | ||||
Given the full path to a file or folder in file-path, this function returns the file or folder's comments (as displayed in the Finder's Get Info window). |
getFileCreator ( file-path ) |
Returns: string | Location: FileLib | ||||
Given the full path to a file in file-path, this function will return its creator string. Example: print getFileCreator(template_path & template_name); >> R*ch |
getFileSize ( file-path ) |
Returns: integer | Location: FileLib | ||||
Given the full path in file-path, the file's size in bytes will be returned as an integer. The size is based on the data fork only, so any resources will not be included in the returned file size. Example: log_size = getFileSize(site_path & "WebSTAR.log"); print "WebSTAR log file is " & (log_size / 1024 as float(,2)) & "K."; >> WebSTAR log file is 465K. |
getFileType ( file-path ) |
Returns: string | Location: FileLib | ||||
Given the full path to a file in file-path, this function will return its file type as a string. Example: print getFileType(template_path & template_name); >> TEXT |
getFolderContents ( folder-path ) |
Returns: list | Location: FileLib | ||||
Given a full path to a folder in folder-path, a list of its contents as full paths will be returned. Folders in the list are returned with a colon appended to their name, as in "Folder:". The isFolder() function is an alternative method of detecting whether or not an item is a folder. Example: print getFolderContents(template_path);; >> Hard Drive:Web Site:file_lister.t Hard Drive:Web Site:images: |
getModDate ( file-path ) |
Returns: string | Location: FileLib | ||||
Given the full path file-path, the file's modification date and time will be returned as a string containing both parts in short form. This string is suitable for passing to the date and time functions. Example: // Get the template's modification date. print getModDate(template_path & template_name); >> 7/5/96 10:16:27 PM |
getResource ( file-path, resource-type, resource-ref ) |
Returns: binary | Location: FileLib | ||||||||
Given a resource type in resource-type and an individual name or ID in resource-ref, this function will return the contents of the resource as a binary object. The full path to the resource file is specified in file-path. See Also: |
getResourceID ( file-path, resource-type, resource-number ) |
Returns: integer | Location: FileLib | ||||||||
Given a resource type in resource-type and a sequential number in resource-number, the resource's ID is returned. The full path to the resource file is specified in file-path. |
getStringResource ( file-path, resource-ref [, index ]) |
Returns: string | Location: FileLib | ||||||||
Returns the contents of the "STR " resource whose ID is resource-ref. If an optional index is provided, the appropriate string from a "STR#" resource will be returned. The full path to the resource file is specified in file-path. |
isAlias ( file-path ) |
Returns: boolean | Location: FileLib | ||||
Given the full path to a file or folder in file-path, a boolean will be returned indicating whether or not the path points to an alias. Example:
|
isFolder ( file-path ) |
Returns: boolean | Location: FileLib | ||||
Given the full path to a file in file-path, a boolean will be returned indicating whether or not the path points to a folder. Example:
|
makeAlias ( file-path, alias-path ) |
Returns: null | Location: FileLib | ||||||
Given the full path to an existing file in file-path, this function creates an alias to the file at the location specified as a full path in alias-path. The alias-path parameter may be a folder destination path or a full file path. |
makeFile ( file-path [, file-creator, file-type ]) |
Returns: null | Location: FileLib | ||||||||
Creates a new, empty file whose full path is file-path. The file's creator is specified using the optional file-creator and file-type parameters. If file-creator or file-type is not specified they will be set to BBEdit ("R*ch") and plain text ("TEXT"), respectively. Example:
|
makeFolder ( folder-path ) |
Returns: null | Location: FileLib | ||||
Creates a new folder whose full path is specified in folder-path. |
moveFile ( file-path, new-path ) |
Returns: null | Location: FileLib | ||||||
Moves the file whose full path is file-path to the new location specified by new-path. The new-path parameter may be a destination folder path or full file path. This function will only work with files, not folders. If you need to move a folder, use moveFolder() instead. |
moveFolder ( folder-path, new-path ) |
Returns: null | Location: FileLib | ||||||
Moves the folder whose full path is folder-path to the new location specified by new-path. The new-path parameter must be a folder path, not a path to a file or an error will be returned. This function will only work with folders, not files. If you need to move a file, use moveFile() instead. |
pathToFileName ( file-path ) |
Returns: string | Location: FileLib | ||||
Given a full path to a file in file-path, the file name itself will be returned with no path. If file-path actually points to a folder, the name of the folder will be returned. Example: print template_path & template_name & "\r"; print pathToFileName(template_path & template_name); >> Hard Drive:Web Site:admin:banner_admin.t banner_admin.t |
readBinaryFile ( file-path ) |
Returns: binary | Location: FileLib | ||||
Reads the entire file whose full path is file-path as a binary object. Example: // Read in a GIF image file and return it to the browser. the_image = readBinaryFile(template_path & ":images:ball.gif"); setMIMEType("image/gif"); return the_image; See Also: |
readFile ( file-path [, length, offset ]) |
Returns: string | Location: FileLib | ||||||||
This function reads a text file whose full path is specified by file-path, starting either at the beginning of the file or offset if it is defined, and continuing through to the end of the file or length bytes total. Because the file is read directly into memory, you may need to read large files in smaller chunks or increase WebSiphon's memory allocation. The fourth example below demonstrates how to import a tab-delimited text file into a Verona database. Example:
|
removeFile ( file-path ) |
Returns: null | Location: FileLib | ||||
Premanently deletes the file whose full path is file-path. Warning: This operation is not reversible! |
removeFolder ( folder-path ) |
Returns: null | Location: FileLib | ||||
Premanently deletes the folder whose full path is folder-path. Any items contained within the specified folder will be deleted as well! Warning: This operation is not reversible! |
removeResource ( file-path, resource-type, resource-ref ) |
Returns: null | Location: FileLib | ||||||||
Given the full path to a resource file in file-path, the type in resource-type, and an ID or name in resource-ref, this function permanently deletes the resource. Warning: This operation is not reversible! |
resolveAlias ( alias-path ) |
Returns: string | Location: FileLib | ||||
Given the full path to an alias in alias-path, this function will return the full path to the original file the alias points to. If alias-path is not an alias, the returned value will be the same as was passed in. |
returnBinaryFile ( file-path [, mime-type ]) |
Returns: binary | Location: FileLib | ||||||
Streams the entire file whose full path is file-path as a binary object back to the template. Because the file is streamed then the entire file is not loaded into memory first. The file's MIME type is specified as a string using the optional mime-type parameter. If mime-type is not specified it will use the default type as configured in the web server application. Example:
See Also: |
setFileComments ( file-path, string ) |
Returns: null | Location: FileLib | ||||||
Given the full path to a file or folder in file-path, this function sets the file or folder's comments (as displayed in the Finder's Get Info window) to string. |
setFileCreator ( file-path, new-creator ) |
Returns: null | Location: FileLib | ||||||
Given the full path to a file in file-path, this function sets its creator to the one specified in new-creator. |
setFileName ( file-path, filename ) |
Returns: null | Location: FileLib | ||||||
Given the full path to a file in file-path, this function will change the name of the file to filename. The new filename must be a string and not a path. Example: log_file = site_path & "WebSTAR.log"; setFileName(log_file, "Old WebSTAR.log"); |
setFileType ( file-path, new-type ) |
Returns: null | Location: FileLib | ||||||
Given the full path to a file in file-path, this function will change the file's type to the one specified in new-type. |
setResource ( file-path, resource-type, resource-ref, binary-data ) |
Returns: null | Location: FileLib | ||||||||||
Given the full path to a resource file in file-path, the type in resource-type, and name or ID in resource-ref, this function replaces the resource value with binary-data. See Also: |
writeBinaryFile ( file-path, binary-data ) |
Returns: null | Location: FileLib | ||||||
Writes the value of the binary-data parameter to a file. Any previous contents of the file specified will be replaced, so if you wish to modify a file, you must first read it with readBinaryFile(). The output file will be created if no file exists as specified by file-path. See Also: |
writeFile ( file-path, text ) |
Returns: null | Location: FileLib | ||||||
Writes the value of the text parameter to a text file. Any previous contents of the file specified will be replaced, so if you wish to modify a file, you must first read it with readFile(). The output file will be created if no file exists as specified by file-path. Example:
See Also: |