Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

NSFileWrapperMBS.initDirectoryWithFileWrappers(childrenByPreferredName as Dictionary) as NSFileWrapperMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Initializes the receiver as a directory file wrapper, with a given file-wrapper list.
Notes:
childrenByPreferredName: Key-value dictionary of file wrappers with which to initialize the receiver. The dictionary must contain entries whose values are the file wrappers that are to become children and whose keys are filenames. See Working with Directory Wrappers in File System Programming Guide for more information about the file-wrapper list structure.

Returns initialized file wrapper for fileWrappers.

After initialization, the file wrapper is not associated with a file-system node until you save it using writeToURL:options:originalContentsURL:.

The receiver is initialized with open permissions: anyone can read, write, or modify the directory on disk.

If any file wrapper in the directory doesn’t have a preferred filename, its preferred name is automatically set to its corresponding key in the childrenByPreferredName dictionary.

Feedback, Comments & Corrections

NSFileWrapperMBS.initRegularFileWithContents(data as MemoryBlock) as NSFileWrapperMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacBase Plugin 15.0 Yes No No Yes, macOS only No
Function: Initializes the receiver as a regular-file file wrapper.
Example:
dim content as MemoryBlock = "Hello World"
dim f as NSFileWrapperMBS = NSFileWrapperMBS.initRegularFileWithContents(content)
f.filename = "HelloWorld.txt"
Notes:
After initialization, the file wrapper is not associated with a file-system node until you save it using writeToURL.
The file wrapper is initialized with open permissions: anyone can write to or read the file wrapper.

Feedback, Comments & Corrections

NSFileWrapperMBS.initWithFile(File as folderItem, Options as Integer, byref error as NSErrorMBS) as NSFileWrapperMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacBase Plugin 15.0 Yes No No Yes, macOS only No
Function: Initializes a file wrapper instance whose kind is determined by the type of file-system node located by the folderitem.
Example:
dim file as FolderItem = SpecialFolder.desktop.child("todo.rtf")
dim e as NSErrorMBS
dim f as NSFileWrapperMBS = NSFileWrapperMBS.initWithFile(file, 0, e)

if e <> nil then
MsgBox e.localizedDescription
else
dim dic as Dictionary = f.fileAttributes
Break // read dic in debugger
end if
Notes:
File: Folderitem of the file-system node the file wrapper is to represent.
options: Option flags for reading the node located at folderitem. Can be NSFileWrapperReadingImmediate and/or NSFileWrapperReadingWithoutMapping.
Error: If an error occurs, upon return contains an NSErrorMBS object that describes the problem.

Returns File wrapper for the file-system node at folderitem. May be a directory, file, or symbolic link, depending on what is located at the folderitem. Returns nil if reading is not successful.

If folderitem is a directory, this method recursively creates file wrappers for each node within that directory. Use the fileWrappers property to get the file wrappers of the nodes contained by the directory.

Available in OS X v10.6 and later.

Feedback, Comments & Corrections

NSFileWrapperMBS.initWithSerializedRepresentation(data as MemoryBlock) as NSFileWrapperMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacBase Plugin 15.0 Yes No No Yes, macOS only No
Function: Initializes the receiver as a regular-file file wrapper from given serialized data.
Example:
// get a wrapper
dim file as FolderItem = SpecialFolder.desktop.child("todo.rtf")
dim e as NSErrorMBS
dim f as NSFileWrapperMBS = NSFileWrapperMBS.initWithFile(file, 0, e)
dim data as MemoryBlock = f.serializedRepresentation

// later restore it
dim other as NSFileWrapperMBS = NSFileWrapperMBS.initWithSerializedRepresentation(data)
MsgBox other.preferredFilename
Notes:
serializedRepresentation: Serialized representation of a file wrapper in the format used for the NSFileContentsPboardType pasteboard type. Data of this format is returned by such methods as serializedRepresentation and RTFDFromRange (in NSAttributedString).

Returns regular-file file wrapper initialized from serializedRepresentation.
The file wrapper is not associated with a file-system node until you save it using writeToURL.

Feedback, Comments & Corrections

NSFileWrapperMBS.initWithURL(URL as string, Options as Integer, byref error as NSErrorMBS) as NSFileWrapperMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method Cocoa MBS MacBase Plugin 15.0 Yes No No Yes, macOS only No
Function: Initializes a file wrapper instance whose kind is determined by the type of file-system node located by the URL.
Notes:
url: URL of the file-system node the file wrapper is to represent.
options: Option flags for reading the node located at url. Can be NSFileWrapperReadingImmediate and/or NSFileWrapperReadingWithoutMapping.
Error: If an error occurs, upon return contains an NSErrorMBS object that describes the problem.

Returns File wrapper for the file-system node at url. May be a directory, file, or symbolic link, depending on what is located at the URL. Returns nil if reading is not successful.

If url is a directory, this method recursively creates file wrappers for each node within that directory. Use the fileWrappers property to get the file wrappers of the nodes contained by the directory.

Available in OS X v10.6 and later.

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacBase Plugin.




Links
MBS Xojo Plugins