xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

FileValid()

Tests if a string contains a valid file name.

Syntax

FileValid( <cFileName>     , ;
          [<nMaxName>]     , ;
          [<nMaxExtension>], ;
          [<lNoExtension>] , ;
          [<lSpaces>]        ) --> lIsValid

Arguments

<cFileName>
This is a character string holding a file name. By default, only FAT compatible 8.3 file names are checked (DOS file system).
<nMaxName>
This optional numeric parameter defaults to 8, which is the maximum length of file names for the FAT file system. Pass the value 255 for file systems supporting long file names.
<nMaxExtension>
This optional numeric parameter defaults to 3, which is the maximum length of file extensions for the FAT file system. Pass the value 255 for file systems supporting longer file extensions.
<lNoExtension>
This optional parameter defaults to .T. (true), indicating that the file extension should not be validated. Passing .F. (false) includes the file extension in the validation test.
<lSpaces>
This optional parameter defaults to .F. (false), indicating that blank spaces are illegal in a file name. Passing .F. (false) accepts blank spaces as valid characters of the file name.

Return

The function returns .T. (true) if <cFileName> contains a valid filename, otherwise .F. (false) is returned.

Info

See also:HB_FNameSplit(), Token(), TrueName()
Category: CT:DiskUtil , File functions , Low level file functions
Source:ct\diskutil.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example implements the function LongFileValid() which tests
// if a long file name is valid

   PROCEDURE Main

      ? FileValid( "MyApp.prg" )                   // result: .T.

      ? FileValid( "My New Application.prg" )      // result: .F.

      ? LongFileValid( "My New Application.prg" )  // result: .T.

   RETURN

   FUNCTION LongFileValid( cFileName, lExtension )

      IF Valtype( lExtension ) <> "L"
         lExtension := .F.
      ENDIF

   RETURN FileValid( cFileName, 255, 255, lExtension, .T. )

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe