Table of Contents

Funktion WaitForFileAccess

Informationen

  • Kategorien: Kernel | Klassenformeln
  • Version: 16.0.0.5096
  • Veröffentlichungsdatum: Freitag, 28. Juni 2013
  • Entwickler: Eiteljörge
  • Benötigt Datenbankänderung: Nein
  • Betreff: Funktion WaitForFileAccess

Beschreibung

usage: WaitForFileAccess( «file»[, «timeout(ms)»[, «flags»]] )

This function waits until the file can be access or time-out expired. The flags specify the kind of access are requested. File access will be check all 10 ms by opening the file. If time-out value is 0 this function checks access one time only and return immediately.

«file» Path and name of the file. The path can be relative or absolute. «timeout» Max. time to wait in millisecond. 0 = check only/no wait. «flags» All flags can be combine. If no flags are set then flag Exist is used. 1 = Exist. Wait for the file exists. 2 = Read. Wait for the file can be open for read (shared). 4 = Write. Wait for the file can be open for write (not shared).

«return value» The function returns the same flags as of parameter «flags». 0 = File can be access. other = File cannot be access. Each flag indicate the kind of access which isn't available.

Beispielcode

oncallfunction
{
	var string $sFile;
	var int    $nResult;
	var string $sMsg;

	$sFile = "c:\\tmp\\test.txt";

	$nResult = WaitForFileAccess( $sFile, 5000, 6 );

	if ( $nResult == 0 )
	{
		$sMsg = "Result: accessable";
	}
	else
	{
		$sMsg = "Result: no access due ";
		if ( $nResult & 1 )
		{
			$sMsg = $sMsg + " Exist";
		}
		if ( $nResult & 2 )
		{
			$sMsg = $sMsg + " Read";
		}
		if ( $nResult & 4 )
		{
			$sMsg = $sMsg + " Write";
		}
	}

	MessageBox( $sMsg );
}