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

Next items

folderitem.AccessDateMBS(UTC as boolean = false) as date
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Files MBS Util Plugin 10.1 Yes Yes Yes Yes No
Function: The access date of the file or folder.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.txt")
dim xd as date = f.AccessDateMBS
MsgBox xd.LongDate+" "+xd.LongTime
Notes:
Setting this value is not supported on Linux currently.

To query Spotlight's Last Open day, please check the FAQ for sample code.
If UTC is true, you get/set date object where time is UTC.
(Read and Write computed property)

Some examples which use this property:

Feedback, Comments & Corrections

folderitem.AddedToDirectoryDateMBS as date
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin 16.4 Yes No No Yes, macOS only No
Function: Returns the date the file was added to the folder.
Notes: Requires OS X 10.10 or newer.

Feedback, Comments & Corrections

folderitem.AttributeModificationDateMBS(UTC as boolean = false) as date
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Files MBS Util Plugin 10.1 Yes Yes Yes Yes No
Function: The attribute modification date of the file or folder.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.txt")
dim xd as date = f.AttributeModificationDateMBS
MsgBox xd.LongDate+" "+xd.LongTime
Notes:
Attribute Motification dates are supported only on Mac OS X currently.
If UTC is true, you get/set date object where time is UTC.
(Read and Write computed property)

Some examples which use this property:

Feedback, Comments & Corrections

folderitem.BackupDateMBS(UTC as boolean = false) as date
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Files MBS Util Plugin 10.1 Yes No No Yes, macOS only No
Function: The backup date of the file or folder.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.txt")
dim xd as date = f.BackupDateMBS
MsgBox xd.LongDate+" "+xd.LongTime
Notes:
Backup dates are supported only on Mac OS X currently.
If UTC is true, you get/set date object where time is UTC.
(Read and Write computed property)

Some examples which use this property:

Feedback, Comments & Corrections

Folderitem.BackupIsItemExcludedMBS(byref excludeByPath as boolean) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacFrameworks Plugin 7.7 Yes No No Yes, macOS only No
Function: Report whether or not an item is being excluded from backup.
Notes:

excludeByPath: pass a boolean variable to determine whether or not the given item is excluded as an absolute path or whether it is sticky to the item.

Returns true if the item or any of its ancestors are excluded from backup, false otherwise.

Require Mac OS X 10.5.

Feedback, Comments & Corrections

Folderitem.BackupItemExcludedMBS as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Files MBS MacFrameworks Plugin 7.7 Yes No No Yes, macOS only No
Function: Whether or not an item is being excluded from backup.
Notes:
This is the easy method to just query whether a file is marked as being excluded from backup. You can assign a boolean value to exclude (true) or include (false) the file.

Require Mac OS X 10.5. Returns false on all other operation systems.
(Read and Write computed property)

Feedback, Comments & Corrections

Folderitem.BackupSetItemExcludedMBS(exclude as boolean, excludeByPath as boolean) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacFrameworks Plugin 7.7 Yes No No Yes, macOS only No
Function: Add or remove an item from the list of items excluded from backup.
Notes:
When backing up, the backup daemon skips items marked by this call. If a folder is marked for exclusion, it and its contents are excluded from backup. When specifying by path, it is OK to pass a URL of an item/folder that does not exist yet.

Returns the error code. -1 is the error code in case the function is not available.
Require Mac OS X 10.5.

Feedback, Comments & Corrections

folderitem.CalculateDirectorySizeMBS(recursive as boolean = false, ticks as Integer = 0, QueryCompressedSizes as boolean = false, RecursionLimit as Integer = -1) as DirectorySizeMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin 3.3 Yes Yes Yes Yes No
Function: Returns an object with informations about the folder size.
Example:
// chose a folder
dim f as FolderItem = SelectFolder

// calculate
dim d as DirectorySizeMBS = f.CalculateDirectorySizeMBS(True,0)

// display
MsgBox str(d.FilesCount)+" files in "+str(d.FolderCount)+" folder"
Notes:
recursive: Whether to count items in the subfolders.
ticks: Whether to yield time to other threads. (See YieldTicks property)
QueryCompressedSizes: Whether to query compressed file sizes on Windows.
RecursionLimit: If positive, the recursion limit.

Returns nil on any error.

Some examples which use this method:

Feedback, Comments & Corrections

Folderitem.CommentMBS as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Files MBS MacClassic Plugin Yes No No Yes, macOS only No
Function: The comment for that file.
Example:
dim f as folderitem // your file
f.CommentMBS="Hello world!"
Notes:
The comment is limited in Mac OS 9 to 200 chars. (The actual length depends on the file system.)
(Starting with plugin version 3.4 the Carbon code also reads and writes the Classic comment.)
On Realbasic 5.x the plugin version 3.4 converts the string to MacRoman encoding for the Classic comment.
This function sends an AppleEvent to the Finder. It may take some milliseconds.
(on Mac OS X)

Querying comment is not thread safe.
(Read and Write computed property)

Some examples which use this property:

Feedback, Comments & Corrections

folderitem.CompressedFileLengthMBS as int64
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin 7.4 Yes Yes Yes Yes No
Function: Returns the length of the compressed file on disk.
Example:
filesize.text=format(file.CompressedFileLengthMBS,"0")
Notes: On Windows files can be compressed and this function returns the size of the compressed file. On Mac and for non compressed files on Windows this function returns the uncompressed size.

Feedback, Comments & Corrections

Folderitem.CountMBS as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacClassic Plugin 3.2 Yes Yes No Yes No
Function: Returns the number of items in this folder.
Example:
dim f as FolderItem = SpecialFolder.Desktop
MsgBox str(F.Count)+" vs. "+str(F.CountMBS)
This item is deprecated and should no longer be used. You can use folderitem.Count instead.
Notes:
The count property of the REALbasic folderitem class is cached.
So if you create a file, the count property may not update.

If you need a more up to date value, you can use the CountMBS function to return the value the Mac OS system software returns.
On any error (e.g. invalid folderitem) the function returns 0.

Windows support added in 4.2dr2.

Some examples which use this method:

Feedback, Comments & Corrections

Folderitem.CreateLargeBinaryStreamMBS(MacType as string, MacCreator as string) as LargeBinaryStreamMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin Yes Yes Yes Yes No
Function: Creates a file as a LargeBinaryStreamMBS.
Example:
dim f as FolderItem // your file
dim l as LargeBinaryStreamMBS

l=f.CreateLargeBinaryStreamMBS("TEXT","ttxt")
Notes:
If there is already a file, it is deleted.
On Windows the parameters are ignored.
Returns nil on any error.

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.CreateResStreamMBS(MacType as string, MacCreator as string) as ResStreamMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin Yes No No Yes, macOS only No
Function: Creates a new ResStreamMBS.
Notes:
If there is already a file, it is deleted.
If the file could not be created it is deleted.
Returns nil on any error.

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.CreationDateMBS(UTC as boolean = false) as date
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Files MBS Util Plugin 10.1 Yes Yes Yes Yes No
Function: The creation date of the file or folder.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.txt")
dim xd as date = f.CreationDateMBS
MsgBox xd.LongDate+" "+xd.LongTime
Notes:
Setting this value is not supported on Linux currently.
If UTC is true, you get/set date object where time is UTC.
(Read and Write computed property)

Some examples which use this property:

Feedback, Comments & Corrections

Folderitem.CreatorAppMBS as FolderItem
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacClassic Plugin Yes No No Yes, macOS only No
Function: Returns the application that would be launched if you'd call the above Launch method, or NIL if no appropriate app can be located.
Example:
dim docfile as folderitem // your document file
dim appfile as folderitem
appfile=docfile.CreatorAppMBS
Notes:
This function doesn't work with bundles and should be only used on Mac OS 9.
Use Launch service functions on Mac OS X.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

Folderitem.CreatorAppMBS(creatorCode as String) as FolderItem
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacClassic Plugin Yes No No Yes, macOS only No
Function: Returns a folderitem to the Application which created this file for the given creator code on the volume of the folderitem.
Example:
dim myvolume as folderitem // your volume
dim theFile as folderitem // your file
dim appfile as folderitem
dim ok as boolean
dim inFront as Boolean


appfile=myvolume.CreatorAppMBS("iCAB")
' or
ok = theFile.OpenWithAppMBS(myvolume.CreatorAppMBS("RSED"), inFront)
Notes:
Returns the application that would be launched if you'd call the above Launch method and if the file had the specified creator code. Returns NIL if no appropriate app can be located.

This method allows you to open a document with a creator code that you specify instead of having to locate the application by your own. Here's an example on how to open any file with ResEdit (whose creator code is 'RSED'):

This function doesn't work with bundles and should be only used on Mac OS 9.
Use Launch service functions on Mac OS X.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.DarwinMediaClassMBS as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacCF Plugin 3.1 Yes No No Yes, macOS only No
Function: Returns the class of the media.
Example:
dim f as FolderItem = SpecialFolder.Desktop

MsgBox f.DarwinMediaClassMBS
Notes:
Returns nil on any problem.

Possible values:
kIOCDMediaClass"IOCDMedia"
kIODVDMediaClass"IODVDMedia"
kIOMediaClass"IOMedia"

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.DarwinMediaInfoMBS as CFDictionaryMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacCF Plugin 5.1 Yes No No Yes, macOS only No
Function: Returns the info dictionary of the media.
Example:
// info for boot volume
dim info as CFDictionaryMBS = volume(0).DarwinMediaInfoMBS

if info = nil then
beep // error
else
CFShowMBS info // show in console

dim RemovableKey as CFStringMBS = NewCFStringMBS("Removable")
dim RemovableCFO as CFObjectMBS = info.Value(RemovableKey)
dim RemovableCFB as CFBooleanMBS = CFBooleanMBS(RemovableCFO)
dim Removable as Boolean = RemovableCFB.Value

MsgBox "Removable: "+str(Removable)

dim EjectableKey as CFStringMBS = NewCFStringMBS("Ejectable")
dim EjectableCFO as CFObjectMBS = info.Value(EjectableKey)
dim EjectableCFB as CFBooleanMBS = CFBooleanMBS(EjectableCFO)
dim Ejectable as Boolean = EjectableCFB.Value

MsgBox "Ejectable: "+str(Ejectable)

dim SizeKey as CFStringMBS = NewCFStringMBS("Size")
dim SizeCFO as CFObjectMBS = info.Value(SizeKey)
dim SizeCFN as CFNumberMBS = CFNumberMBS(SizeCFO)
dim Size as Double = SizeCFN.doubleValue / 1000000000.0

MsgBox "Size: "+str(Size, "0.0")+" GB"
end if
Notes:
Returns nil on any problem.

example output for the example code above:
<CFDictionary 0x7d60510 [0xa01900e0]>{type = fixed-mutable, count = 14, capacity = 14, pairs = (
0 : <CFString 0x7d5ffe0 [0xa01900e0]>{contents = "Leaf"} = <CFBoolean 0xa0190b98 [0xa01900e0]>{value = false}
1 : <CFString 0x7d60160 [0xa01900e0]>{contents = "Writable"} = <CFBoolean 0xa0190b90 [0xa01900e0]>{value = true}
2 : <CFString 0x7d60310 [0xa01900e0]>{contents = "BSD Minor"} = <CFNumber 0x7d60300 [0xa01900e0]>{value = +0, type = kCFNumberSInt32Type}
6 : <CFString 0x7d60040 [0xa01900e0]>{contents = "Preferred Block Size"} = <CFNumber 0x7d5fe90 [0xa01900e0]>{value = +512, type = kCFNumberSInt64Type}
11 : <CFString 0x7d604c0 [0xa01900e0]>{contents = "BSD Major"} = <CFNumber 0x7d604b0 [0xa01900e0]>{value = +14, type = kCFNumberSInt32Type}
13 : <CFString 0x7d603b0 [0xa01900e0]>{contents = "BSD Name"} = <CFString 0x7d60110 [0xa01900e0]>{contents = "disk0"}
14 : <CFString 0x7d600d0 [0xa01900e0]>{contents = "Size"} = <CFNumber 0x7d60090 [0xa01900e0]>{value = +163928604672, type = kCFNumberSInt64Type}
15 : <CFString 0x7d5fef0 [0xa01900e0]>{contents = "Content Hint"} = <CFString 0xa0196304 [0xa01900e0]>{contents = ""}
16 : <CFString 0x7d60020 [0xa01900e0]>{contents = "Removable"} = <CFBoolean 0xa0190b98 [0xa01900e0]>{value = false}
17 : <CFString 0x7d601b0 [0xa01900e0]>{contents = "IOMediaIcon"} = <CFDictionary 0x7d60360 [0xa01900e0]>{type = fixed-mutable, count = 2, capacity = 2, pairs = (
2 : <CFString 0x7d60250 [0xa01900e0]>{contents = "CFBundleIdentifier"} = <CFString 0x7d602a0 [0xa01900e0]>{contents = "com.apple.iokit.IOStorageFamily"}
3 : <CFString 0x7d5ff30 [0xa01900e0]>{contents = "IOBundleResourceFile"} = <CFString 0x7d60230 [0xa01900e0]>{contents = "Internal.icns"}
)}
19 : <CFString 0x7d603d0 [0xa01900e0]>{contents = "BSD Unit"} = <CFNumber 0x7d5ff50 [0xa01900e0]>{value = +0, type = kCFNumberSInt32Type}
20 : <CFString 0x7d5ff90 [0xa01900e0]>{contents = "Ejectable"} = <CFBoolean 0xa0190b98 [0xa01900e0]>{value = false}
21 : <CFString 0x7d5fea0 [0xa01900e0]>{contents = "Content"} = <CFString 0x7d5ff10 [0xa01900e0]>{contents = "Apple_partition_scheme"}
22 : <CFString 0x7d60120 [0xa01900e0]>{contents = "Whole"} = <CFBoolean 0xa0190b90 [0xa01900e0]>{value = true}
)}

If you don't like all the CFDictionaryMBS methods, than use Dictionary function it to get a Xojo dictionary.

Feedback, Comments & Corrections

folderitem.DarwinVolumeNameMBS as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacCF Plugin 3.1 Yes No No Yes, macOS only No
Function: Returns the name of the volume from the BSD part of Mac OS X.
Example:
MsgBox Volume(0).DarwinVolumeNameMBS // shows here disk1s10
Notes:
Returns "" on any error.
The returned string is encoded as ASCII.

Some examples which use this method:

Feedback, Comments & Corrections

Folderitem.DeleteDataForkMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin Yes No No Yes, macOS only No
Function: Deletes the data fork of a file.
Notes:
Equal to open the file using a binarystream and setting the length property to 0.
On Mac OS a file can exist without a datafork, with a resource fork or even without any fork.

Feedback, Comments & Corrections

Folderitem.DeleteResourceForkMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin Yes No No Yes, macOS only No
Function: Deletes the resource fork of a file.
Notes:
Equal to open the file using a ResStreamMBS and setting the length property to 0.
On Mac OS a file can exist without a datafork, with a resource fork or even without any fork.

Feedback, Comments & Corrections

folderitem.DisplayPathMBS(delimiter as string = "/") as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin 9.8 Yes Yes Yes Yes No
Function: Shows display path.
Example:
// Sample values in German:

// SnowLeopard/Programme/Dienstprogramme/Konsole

MsgBox SpecialFolder.Applications.Child("Utilities").Child("Console.app").DisplayPathMBS("/")

// SnowLeopard/Benutzer/cs/Schreibtisch

MsgBox SpecialFolder.Desktop.DisplayPathMBS("/")

// SnowLeopard ➜ Programme ➜ Dienstprogramme ➜ Konsole

MsgBox SpecialFolder.Applications.Child("Utilities").Child("Console.app").DisplayPathMBS(" ➜ ")

// SnowLeopard ➜ Benutzer ➜ cs ➜ Schreibtisch

MsgBox SpecialFolder.Desktop.DisplayPathMBS(" ➜ ")
Notes: You can pass any string for delimiter. Good looks an arrow or just a slash.

Feedback, Comments & Corrections

folderitem.EjectVolumeMBS(force as boolean, byref dissenterPID as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacClassic Plugin 10.3 Yes No No Yes, macOS only No
Function: This routine ejects the volume specified by folderitem.
Example:
dim disk as FolderItem

dim c as Integer = VolumeCount-1
for i as Integer = 0 to c
dim v as FolderItem = volume(i)
if v.Name = "testvolume" then
disk = v
exit
end if
next

if disk = nil then
MsgBox "Please change the name in this code."
else
dim pid as Integer
dim e as Integer = disk.EjectVolumeMBS(false, pid)

if e=0 then
msgBox "Volume unmounted."
else

if pid=0 then
msgBox "Failed to unmount with error: "+str(e)
else
dim name as string
dim p as new ProcessMBS // from Util plugin
p.GetFirstProcess

do
if p.ProcessID = pid then
name = p.Name
end if
loop until not p.GetNextProcess

if len(name)>0 then
msgBox "Failed to unmount with error: "+str(e)
else
MsgBox "Failed to unmount."+EndOfLine+EndOfLine+"The application "+name+" is still using this volume."+EndOfLine+"Error: "+str(e)
end if

end if
end if
end if
Notes:
If the volume cannot be ejected the pid of the process which denied the unmount will be returned in the dissenter parameter. This routine returns after the eject is complete. Ejecting a volume will result in the unmounting of other volumes on the same device.

force: Specify true if you want the volume forcibly unmounted. Force unmounting a volume will very likely result in data loss since the volume will be ejected even if there are open files on it. This option should be reserved for situations such as the backing store for a volume is gone (so the data is lost regardless).
dissenterPID: Optionally, pid of the process which denied the unmount if the unmount is denied.

Returns a Mac OS error code. 0 means no error and -1 is a plugin error if the function can't be called. -47 is returned if the disc is in use.

PS: Seems like on my tests the pid is not set by Apple.

Feedback, Comments & Corrections

FolderItem.FilesMBS as Folderitem()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin 12.0 Yes Yes Yes Yes No
Function: Returns array of files in the given folder.
Example:
dim folder as FolderItem = SpecialFolder.Desktop
dim files() as FolderItem = folder.FilesMBS
MsgBox str(UBound(files)+1)+" files"
Notes: Similar to item() function, but returns all files with one call.

Feedback, Comments & Corrections

Folderitem.FinderLabelMBS as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Files MBS MacClassic Plugin Yes No No Yes, macOS only No
Function: Returns the color code for the file.
Example:
file.FinderLabelMBS=2
Notes:
The file label is a number between 0 and 7 to give the file a color.
Used in the Classic Finder for labels (and on Mac OS X for Finder replacement or Finder extending utilities)
On reading the value you can get negative values like -43 if the file is not found.

To know labels and colors, please use NSWorkspaceMBS.fileLabelColors and NSWorkspaceMBS.fileLabels methods.
(Read and Write computed property)

Feedback, Comments & Corrections

Folderitem.FlushVolumeMBS as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacClassic Plugin 3.3 Yes No No Yes, macOS only No
Function: Asks the Mac OS to flush all write buffers to the disc.

Feedback, Comments & Corrections

FolderItemToPathMBS(file as folderitem) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Files MBS MacOSX Plugin Yes No No Yes, macOS only No
Function: Returns a unix path for the given folderitem.
Notes:
Works only on Mac OS X.
This function is not very good, as Apple doesn't document for FSRefMakePath what path it returns, which encoding the path uses (maybe UTF8) and when it fails.
(e.g. it currently doesn't work for volumes)

Feedback, Comments & Corrections

FolderItem.FoldersMBS as Folderitem()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin 12.0 Yes Yes Yes Yes No
Function: Returns array of folders in the given folder.
Example:
dim folder as FolderItem = SpecialFolder.Desktop
dim folders() as FolderItem = folder.FoldersMBS
MsgBox str(UBound(folders)+1)+" folders"
Notes: Similar to item() function, but returns all folders with one call.

Feedback, Comments & Corrections

Folderitem.FSRefMBS as memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin Yes No No Yes, macOS only No
Function: Returns the FSRef to this folderitem as a memoryblock.
Notes:
Only useful for toolbox calls.
Requires Mac OS X or Mac OS 9.
If the folderitem's file doesn't exist, you get the parent folder's FSRef.

Feedback, Comments & Corrections

Next items

The items on this page are in the following plugins: MBS MacCF Plugin, MBS MacClassic Plugin, MBS MacFrameworks Plugin, MBS MacOSX Plugin, MBS Util Plugin.




Links
MBS FileMaker tutorial videos