FC_GetDirSize - General Information

Overview

Type:

Function

Available as of:

SystemInterface_1.34.1.0

Support for:

-

Versions:

Current version

Task

Determine the size of the complete content of a directory.

Description

The function runs through the complete directory content recursively and adds up the sizes of the files and folders. The size of directories in the RAM disk ("ram0:"), on the flash disk ("ide0:") and on a USB device ("/usb2msd16a" or "/usb2msd16b") can be read out.

The default device is "ide0:".

Interface

Input

Data type

Description

i_sDirPath

STRING[1023]

Name of the directory whose size has to be determined

Input/Output

Data type

Description

iq_uliDirSize

ULINT

Size of the directory content in byte

Return Value

Data type

Description

DINT

0: Size has been read out successfully

-1: Error when reading the size

-318: At least one of the parameters is invalid

Example

Requirement

The size of the directory "ide0:/ESystem" shall be determined in Mb.

Declaration

PROGRAM ESystemDirSize
VAR
   uliDirSize : ULINT := 0;
   diStatus : DINT := 0; 
   diBytesOfMegaByte : DINT := 1048576; // = 1024 * 1024 
   diDirSizeInMB : LINT := 0; 
END_VAR

Program

diStatus = FC_GetDirSize ( 'ide0:/ESystem', uliDirSize ); 
IF (diStatus = 0) THEN 
   diBytesOfMegaByte:= ULINT_TO_LINT(uliDirSize) / diBytesOfMegaByte; 
END_IF  

Result

diBytesOfMegaByte contains the size of the directory in mega byte.

NOTE: In this case, you could call up FC_GetDirSize ( 'ESystem', uliDirSize ) too and the result would be the same. But if you want to determine the size of a directory on another data carrier than the internal flash disk (USB device, RAM disk), then add the device name in the path or else the resolution is not possible.