Xojo Conferences
XDCMay2019MiamiUSA
MBSOct2019CologneDE

Platforms to show: All Mac Windows Linux Cross-Platform

Previous items

folderitem.PhysicalFileDataLengthMBS 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 physical disk space used for this file's data fork.
Example:
filesize.text=format(file.PhysicalFileDataLengthMBS,"0")
Notes:
This function works for files bigger than 2 GB which RB's built in functions don't.
On Windows the physical size reported is equal to the logical size, because there is no function for the physical size.

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.PhysicalFileResLengthMBS 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 physical disk space used for this file's resourcefork.
Example:
filesize.text=format(file.PhysicalFileResLengthMBS,"0")
Notes:
This function works for files bigger than 2 GB which RB's built in functions don't.
On Windows the physical size reported is equal to the logical size, because there is no function for the physical size.

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.PhysicalFileTotalLengthMBS 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 physical disk space used for this file.
Example:
filesize.text=format(file.PhysicalFileTotalLengthMBS,"0")
Notes:
This function works for files bigger than 2 GB which RB's built in functions don't.
On Windows the physical size reported is equal to the logical size, because there is no function for the physical size.

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.ReadFileMBS(byref data as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin 19.0 Yes Yes Yes Yes No
Function: Reads a file.
Notes:
Reads content of file and returns it in data parameter.
Returns true on success of false on failure.

See also WriteFileMBS function.

Feedback, Comments & Corrections

Folderitem.SetFileFlagsMBS(flags as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacClassic Plugin Yes No No Yes, macOS only No
Function: Set the file flags for the folderitem to the given value. Returns 0 if okay.
Example:
dim f as FolderItem
dim err, fdFlags as Integer

// For example, clearing a file's hasCustomIcon flag works like this:
fdFlags = f.GetFileFlagsMBS
if fdFlags >= 0 then
err = f.SetFileFlagsMBS(BitExclMBS(fdFlags, 10))
if err <> 0 then
// ... oops, an error occured
// (for instance, the disk could be write protected)
end
end
Notes:
Sets the fdFlags of a file. Returns an error code (or zero if no error occured). Possible error conditions include "disk is write protected" and "file not found".
When changing flags of a file, use GetFileFlags to get the original flags, then clear or set the flags by using BitwiseAnd and BitwiseOr and call SetFileFlags to set the new flags.

Some examples which use this method:

Feedback, Comments & Corrections

Folderitem.SetFolderFlagsMBS(flags as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacClassic Plugin Yes No No Yes, macOS only No
Function: Set the folder flags for the folderitem to the given value. Returns 0 if okay.
Example:
Dim f As FolderItem = GetFolderItem("test") // some folder
If f.SetFolderFlagsMBS(BitwiseOr(f.GetFolderFlagsMBS, 4)) <> 0 Then
MsgBox "Can't set label to green."
End If
Notes:
Sets the frFlags of a folder. Returns an error code (or zero if no error occured). Possible error conditions include "disk is write protected" and "folder not found".
When changing flags of a folder, use GetFolderFlags to get the original flags, then clear or set the flags by using BitwiseAnd and BitwiseOr and call SetFolderFlags to set the new flags.

with values 2, 4 and 8 in the flags, you control the label color in Finder. Example code above uses 4 which is green by default.

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.SetTagNamesMBS(tags() as string) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacCF Plugin 13.5 Yes No No Yes, macOS only No
Function: Sets file tags.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.xojo_binary_project")

dim Tags() as string = Array("Hello", "World")
dim e as Integer = f.SetTagNamesMBS(tags)

MsgBox "SetTagNamesMBS: "+str(e)
Notes:
tags() is array with new tag names.
Provides error code as return value and details about error in CFErrorMBS object.
Requires Mac OS X 10.9 or newer.
Please note that some tags may include chr(10) followed by a number to indicate which label color is used for compatibility to older OS X versions.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.SetTagNamesMBS(tags() as string, byref e as CFErrorMBS) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacCF Plugin 13.5 Yes No No Yes, macOS only No
Function: Sets file tags.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.xojo_binary_project")

dim Tags() as string = Array("Hello", "World")
dim ce as CFErrorMBS
dim e as Integer = f.SetTagNamesMBS(tags, ce)

if ce <> nil then
MsgBox "SetTagNamesMBS: "+str(e)+EndOfLine+ce.Description
else
MsgBox "SetTagNamesMBS: "+str(e)
end if
Notes:
tags() is array with new tag names.
Provides error code as return value and details about error in CFErrorMBS object.
Requires Mac OS X 10.9 or newer.
Please note that some tags may include chr(10) followed by a number to indicate which label color is used for compatibility to older OS X versions.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

Folderitem.ShortPathMBS as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Win Plugin No Yes No No No
Function: Returns the short path for the file.
Example:
dim f as folderitem = specialfolder.desktop.child("test.file")
msgbox f.ShortPathMBS
Notes:
In contrast to long path this is the short 8.3 path for Windows.
You need this for the WindowsMCI object.
Works with Windows NT 4 or newer.

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.TagNamesMBS as string()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacCF Plugin 13.5 Yes No No Yes, macOS only No
Function: Queries tag names for a file or folder.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.xojo_binary_project")
dim Tags() as string = f.TagNamesMBS
MsgBox "Tags: "+Join(tags, EndOfLine)
Notes:
Requires Mac OS X 10.9 or newer.
Optionally provides error information in CFErrorMBS object.
Please note that some tags may include chr(10) followed by a number to indicate which label color is used for compatibility to older OS X versions.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.TagNamesMBS(byref e as CFErrorMBS) as string()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacCF Plugin 13.5 Yes No No Yes, macOS only No
Function: Queries tag names for a file or folder.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.xojo_binary_project")

dim ce as CFErrorMBS
dim Tags() as string = f.TagNamesMBS(ce)

if ce <> nil then
MsgBox "Failed: "+ce.Description
else
MsgBox "Tags: "+Join(tags, EndOfLine)
end if
Notes:
Requires Mac OS X 10.9 or newer.
Optionally provides error information in CFErrorMBS object.
Please note that some tags may include chr(10) followed by a number to indicate which label color is used for compatibility to older OS X versions.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

FolderItem.TrueFilesMBS 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.TrueFilesMBS
MsgBox str(UBound(files)+1)+" files"
Notes: Similar to trueitem() function, but returns all files with one call.

Feedback, Comments & Corrections

FolderItem.TrueFoldersMBS 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.TrueFoldersMBS
MsgBox str(UBound(folders)+1)+" folders"
Notes: Similar to trueitem() function, but returns all folders with one call.

Some examples which use this method:

Feedback, Comments & Corrections

FolderItem.TrueItemsMBS 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 items in the given folder.
Example:
dim folder as FolderItem = SpecialFolder.Desktop
dim Items() as FolderItem = folder.TrueItemsMBS
MsgBox str(UBound(Items)+1)+" items"
Notes: Similar to trueitem() function, but returns all items with one call.

Feedback, Comments & Corrections

Folderitem.UnixpathMBS as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacOSX Plugin Yes Yes No Yes No
Function: Returns the native path for the file.
Example:
dim sh as Shell
dim fi as FolderItem
dim s as String
dim t as TextConverter

sh = new Shell
fi = getfolderitem("test √") // or try some other file name

if fi = nil or fi.exists = false then
beep
return
end if

s="ls -al """ + fi.Unixpathmbs + """"

sh.Execute s
MsgBox sh.Result
Notes:
test on the Desktop could be this:
On Mac OS X: /Users/cs/Desktop/test
On Mac OS 9: Mac OS 9:Desktop folder:test
On Windows: c:\windows\desktop\test

This function will return an empty string if the path can not be encoded in a Xojo String. For my tests ICQ's path which is includes the folder name "ICQ 3.0 ƒ" can not be converted to MacRoman for some reason.

On Mac OS X this function returns the posix path. So if you are looking for POSIXPathMBS or PosixPath this method is it.
This function should do the same as NativePath in Xojo 2013r1.

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.UnMountVolumeMBS(force as boolean = false) 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 unmounts the volume specified by the 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 = "monikajuchmes" then
disk = v
exit
end if
next

if disk = nil then
MsgBox "Please change the name in this code."
else
dim e as Integer = disk.UnMountVolumeMBS

if e=0 then
msgBox "Volume unmounted."
else
msgBox "There was an error!"
end if
end if
Notes:
If the volume cannot be unmounted the pid of the process which denied the unmount will be returned in the dissenterPID parameter.
This routine returns after the unmount is complete.

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.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.UnMountVolumeMBS(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 unmounts the volume specified by the 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.UnMountVolumeMBS(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 unmounted the pid of the process which denied the unmount will be returned in the dissenterPID parameter.
This routine returns after the unmount is complete.

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.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

Folderitem.VolGetFolderItemIDMBS(createFileIDs as Boolean = true) as Integer
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 unique FileID or DirID of a FolderItem.
Notes:
Returns the unique FileID or DirID of a FolderItem. This ID is unique over all items on the same volume. The value 2 always identifies the root directory, all negative values and positive ones above 15 are used for user-created files and folders, while the values 3-15 are used internally by the File System (for the Desktop Database, for example).
If the item does not exists, 0 (zero) is returned instead.

IDs for Folders can always be resolved back to a FolderItem using VolResolveID, while resolving FileIDs only works when they've previously been created explicitly. To create a resolvable FileID, pass true to the createFileIDs parameter. But be aware that if the FileID can not be created (because the disk is locked or because the File System Format does not support it), the call will fail and a zero will be returned!

So, if you are just interested in reading the FileID, pass false to the second parameter. This will not fail even there hasn't been created a resolvable ID for that file yet.

Feedback, Comments & Corrections

Folderitem.VolumeFreeSizeKBMBS as Int64
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin Yes Yes No Yes No
Function: Returns the size on the free space on volume which the folderitem objects points to.
Example:
msgBox "The volume with your system folder has "+str(specialfolder.system.volumeFreeSizeKBMBS)+" KBytes free."
This item is deprecated and should no longer be used. You can use VolumeFreeSizeMBS instead.
Notes:
This can't work with anything bigger than 2048 Gigabytes (until version 10.0).
Return value changed in version 10.0 from integer to SInt64.

Added Linux support in version 16.0.

Some examples which use this method:

Feedback, Comments & Corrections

Folderitem.VolumeFreeSizeMBS as Int64
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin Yes Yes No Yes No
Function: Returns the size of the free space of the volume which the folderitem objects points to.
Example:
// 1. a short:
msgBox "The volume with your system folder has "+str(specialfolder.system.VolumeFreeSizeMBS)+" Bytes free."
// 2. a nicer:
dim d as Double
dim s as string

d=specialfolder.system.VolumeFreeSizeMBS

if d>10000.0 then
if d>10000000.0 then
if d>10000000000.0 then
s=format(d/1024.0/1024.0/1024.0,"0")+" GigaBytes"
else
s=format(d/1024.0/1024.0,"0")+" MegaBytes"
end if
else
s=format(d/1024.0,"0")+" KiloBytes"
end if
else
s=format(d,"0")+" Bytes"
end if

msgBox "On your drive with the system folder you have "+s+" free."
Notes:
This should be used to handle any volume size.
Return value changed in version 10.0 from double to SInt64.

Added Linux support in version 16.0.

Some examples which use this method:

Feedback, Comments & Corrections

Folderitem.VolumeInformationMBS as VolumeInformationMBS
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 VolumeInformationMBS object with detailed information about the volume where the folderitem's file is located on.
Notes: May return nil on errors.

Some examples which use this method:

Feedback, Comments & Corrections

Folderitem.VolumeSizeKBMBS as Int64
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin Yes Yes No Yes No
Function: Returns the Size on the volume which the folderitem objects points to.
Example:
msgBox "The volume with your system folder is "+str(specialfolder.system.volumeSizeKBMBS)+" KB big."
This item is deprecated and should no longer be used. You can use VolumeSizeMBS instead.
Notes:
This can't work with anything bigger than 2048 Gigabytes (until plugin version 10.0).
Return value changed in version 10.0 from integer to SInt64.

Added Linux support in version 16.0.

Some examples which use this method:

Feedback, Comments & Corrections

Folderitem.VolumeSizeMBS as Int64
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin Yes Yes No Yes No
Function: Returns the size on the volume which the folderitem objects points to.
Example:
// 1. a short:
msgBox "The volume with your system folder is "+str(specialfolder.system.volumeSizeMBS)+" big."
// 2. a nicer:
dim d as Double
dim s as string

d=SpecialFolder.System.volumesizeMBS

if d>10000.0 then
if d>10000000.0 then
if d>10000000000.0 then
s=format(d/1024.0/1024.0/1024.0,"0")+" GigaBytes"
else
s=format(d/1024.0/1024.0,"0")+" MegaBytes"
end if
else
s=format(d/1024.0,"0")+" KiloBytes"
end if
else
s=format(d,"0")+" Bytes"
end if

msgBox "Your drive with the system folder is "+s+" big."
Notes:
This should be used to handle any volume size.
Return value changed in version 10.0 from double to SInt64.

Added Linux support in version 16.0.

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.VolumeSupportsHugeFilesMBS as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS MacOSX Plugin 13.3 Yes No No Yes, macOS only No
Function: Queries whether a volume supports 2 TB file size on Mac OS X.
Notes:
Some volumes only support 2 GB or 4 GB file size. Some can handle more than that up to 2 TB.
Returns 0 if not supported, 1 if supported and -1 if unknown.

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.VolumeUUIDMBS as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin 13.0 Yes No No Yes, macOS only No
Function: Queries volume UUID.
Notes: Requires Mac OS X 10.7 or newer.

Feedback, Comments & Corrections

folderitem.WinThumbnailMBS(preferredSize as Integer = 512) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Win Plugin 14.3 No Yes No No No
Function: Queries a thumbnail for an item.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.jpg")
Backdrop = f.WinThumbnailMBS
Notes:
preferredSize is the size you'd like to have. Resulting image can be smaller or bigger.
Returns nil on any error.
If user disabled thumbnails for explorer, the shell also provides none for us, just icons.
Requires Windows Vista or newer.

Feedback, Comments & Corrections

folderitem.WriteFileMBS(data as MemoryBlock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin 19.0 Yes Yes Yes Yes No
Function: Writes a file.
Notes:
Faster than TextOutputStream or BinaryStream on MacOS.

Returns true on success or false on failure.
See also ReadFileMBS function.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

folderitem.WriteFileMBS(data as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Files MBS Util Plugin 19.0 Yes Yes Yes Yes No
Function: Writes a file.
Notes:
Faster than TextOutputStream or BinaryStream on MacOS.

Returns true on success or false on failure.
See also ReadFileMBS function.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

Previous items

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




Links
MBS Xojo Plugins