diskSpace

Typefunction
DictionaryLCS
LibraryLiveCode Script
Syntax
the diskSpace
diskSpace()
Summary

Returns the amount of free space on the disk that holds the defaultFolder.

Introduced1.0
OSmac, windows, linux
Platformsdesktop, server
Example
the diskSpace
put the diskSpace div (1024^2) into megabytesAvailable
if the diskSpace < spaceNeeded then exit mouseUp
Values
NameTypeDescription
return

The diskSpace function returns an integer.

RelatedKeyword: integer
Property: freeSize, size, defaultFolder
Function: hasMemory, volumes, stackSpace
Glossary: download, return value, return, byte
Control Structure: function
Securitydisk
Description

Use the diskSpace function to determine whether there is enough free space to complete an action (such as downloading data).

The value returned by the diskSpace function is in bytes. To convert to kilobytes (K), divide the return value by 1024. To convert to megabytes (M), divide by 1024^2. To convert to gigabytes (G), divide by 1024^3:

function humanReadableDiskSpace theUnits
    set the caseSensitive to false
    switch char 1 of theUnits
        case "k"
            return the diskSpace div 1024
            break
        case "m"
            return the diskSpace div (1024^2)
            break
        case "g"
            return the diskSpace div (1024^3)
            break
        default
            return the diskSpace
            break
    end switch
end humanReadableDiskSpace