Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSFileWrapperMBS class.

NSFileWrapperMBS.initDirectoryWithFileWrappers(childrenByPreferredName as Dictionary) as NSFileWrapperMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 16.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes the receiver as a directory file wrapper, with a given file-wrapper list.

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.

NSFileWrapperMBS.initRegularFileWithContents(data as MemoryBlock) as NSFileWrapperMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 15.0 ✅ Yes ❌ No ❌ No ✅ Yes All
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"

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.

NSFileWrapperMBS.initWithFile(File as folderItem, Options as Integer, byref error as NSErrorMBS) as NSFileWrapperMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 15.0 ✅ Yes ❌ No ❌ No ✅ Yes All
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

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.

NSFileWrapperMBS.initWithSerializedRepresentation(data as MemoryBlock) as NSFileWrapperMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 15.0 ✅ Yes ❌ No ❌ No ✅ Yes All
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

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.

NSFileWrapperMBS.initWithURL(URL as string, Options as Integer, byref error as NSErrorMBS) as NSFileWrapperMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Text MBS MacBase Plugin 15.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes a file wrapper instance whose kind is determined by the type of file-system node located by the URL.

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.

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


The biggest plugin in space...