Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #13250

Re: directory exists

From "Wolfgang Riedmann" <wriedmann@gmail.com>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: directory exists
Date 2021-02-24 13:52 +0100
Message-ID <i9n0ghFgneqU1@mid.individual.net> (permalink)
References <79dc9472-ff50-4839-aaf3-6b5fb026069ao@googlegroups.com> <s13c11$6mq$1@dont-email.me>

Show all headers | View raw


Or even easier:


function IsDirectory( cFileName as string ) as logic
local nReturn		as dword

if Right( cFileName, 1 ) == "\"
	cFileName	:= Left( cFileName, SLen( cFileName ) - 1 )
endif
nReturn := GetFileAttributes( String2Psz( cFileName ) )
if nReturn == 0xFFFFFFFF
	return false
endif

return _And( nReturn, FILE_ATTRIBUTE_DIRECTORY ) ==
FILE_ATTRIBUTE_DIRECTORY

Wolfgang


JohnMartens wrote:

> Hope this can help
> 
> John
> 
> FUNCT IsDir( cDirectory AS STRING ) AS LOGIC
> 	LOCAL lRetVal := TRUE AS LOGIC
> 	LOCAL StruData	IS 	_WINWIN32_FIND_DATA	
> 	LOCAL nHandle	AS PTR
> 	DO CASE
> 	CASE Empty(cDirectory)
> 		lRetVal := FALSE
> 	CASE ! SubStr(cDirectory,2,2) == ':\'
> 		* see if you want full path or not
> 	CASE IsDriveReady(Left(cDirectory,2))
> 		* the drive of the path is not ready
> 	OTHERWISE
> 		lRetVal := FALSE
> 	ENDCASE
> 	*
> 	* check dir on the drive
> 	IF lRetVal	
> 		IF !( Right( cDirectory, 1 ) == "\" )
> 			cDirectory += "\"
> 		ENDIF
> 	
> 		nHandle	:= FindFirstFile( String2Psz( cDirectory+'*.*' ), @StruData
> ) 		IF nHandle =  INVALID_HANDLE_VALUE
> 			lRetVal := FALSE
> 		ELSE
> 			CloseHandle( nHandle )
> 			lRetVal := TRUE		
> 		ENDIF
> 	ENDIF
> RETURN lRetVal
> 
> 
> 
> Op 23-2-2021 om 17:38 schreef aurora baccio:
> > good evening,
> > I must be sure that a directory has been created.
> > Is there a command to search like if (if the path exists) then (if
> > the path does not exist) endif ? ?  Thanks always
> > Aurora Baccio
> > 



-- 

Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

directory exists aurora baccio <aurorabaccio@gmail.com> - 2021-02-23 08:38 -0800
  Re: directory exists JohnMartens <martens@tennishulp.info> - 2021-02-23 17:54 +0100
    Re: directory exists aurora baccio <aurorabaccio@gmail.com> - 2021-02-23 10:06 -0800
    Re: directory exists "Wolfgang Riedmann" <wriedmann@gmail.com> - 2021-02-24 13:52 +0100
  Re: directory exists Fred Killet <killet@killetsoft.de> - 2021-02-25 17:47 +0100
    Re: directory exists Fred Killet <killet@killetsoft.de> - 2021-02-27 09:45 +0100

csiph-web