Restored from previous forum. Originally posted by GPI.
or how can i get the Date of a file?
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
[Implemented] I miss a DirectoryEntryDate() function
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by freak.
Here you go...
viewtopic.php?t=2670
viewtopic.php?t=2610
viewtopic.php?t=3911
Timo
Here you go...
viewtopic.php?t=2670
viewtopic.php?t=2610
viewtopic.php?t=3911
Timo
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by GPI.
OK, i found my ExamineDir-Function
works nearly simular to the directory-library:
One diffrent:
ExamineDir(dir$) need no search pattern and return a handle. If the handle<=0 then a error happend.
NextDirEntry(handle) need this handle.
Edit: DirEntryLastWriteTime() and the other Time-Function returns the Date in the Format of PB, so you can use FormatDate().
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
OK, i found my ExamineDir-Function
Code: Select all
Structure dirfile_data_
dwFileAttributes.l
ftCreationTime.FILETIME
ftLastAccessTime.FILETIME
ftLastWriteTime.FILETIME
nFileSizeHigh.l
nFileSizeLow.l
dwReserved0.l
dwReserved1.l
cFileName.b[ #MAX_PATH ]
cAlternate.b[ 14 ]
DontRead.l ;<- Das brau ich
EndStructure
Global dirfile_ft_.FILETIME
Global dirfile_st_.systemtime
Global dirfile_.dirfile_data_
Procedure ExamineDir(file$)
result = FindFirstFile_(@file$,@dirfile_)
dirfile_\DontRead=1
ProcedureReturn result
EndProcedure
Procedure StopDir(handle)
FindClose_(handle)
EndProcedure
Procedure NextDirEntry(handle)
If dirfile_\DontRead=1
Dirfile_\DontRead=0
x=1
Else
x=findNextFile_(handle,@dirfile_)
EndIf
If x
If dirfile_\dwFileAttributes#FILE_ATTRIBUTE_DIRECTORY
ProcedureReturn 2; verzeichnis
Else
ProcedureReturn 1; datei
EndIf
Else
ProcedureReturn 0; ende
EndIf
EndProcedure
Procedure.s DirEntryName()
ProcedureReturn PeekS(@dirfile_\cFileName[0],#MAX_PATH )
EndProcedure
Procedure.s DirEntryAlternateName()
ProcedureReturn PeekS(@dirfile_\cAlternate[0],14)
EndProcedure
Procedure DirEntryAttributes()
ProcedureReturn dirfile_\dwFileAttributes
EndProcedure
Procedure DirEntryCreationTime()
FileTimeToLocalFileTime_(dirfile_\ftcreationtime,dirfile_ft_)
FileTimeToSystemTime_(dirfile_ft_,dirfile_st_)
ProcedureReturn Date(dirfile_st_\wyear,dirfile_st_\wmonth,dirfile_st_\wday,dirfile_st_\whour,dirfile_st_\wminute,dirfile_st_\wsecond)
EndProcedure
Procedure DirEntryLastAccessTime()
FileTimeToLocalFileTime_(dirfile_\ftlastAccessTime,dirfile_ft_)
FileTimeToSystemTime_(dirfile_ft_,dirfile_st_)
ProcedureReturn Date(dirfile_st_\wyear,dirfile_st_\wmonth,dirfile_st_\wday,dirfile_st_\whour,dirfile_st_\wminute,dirfile_st_\wsecond)
EndProcedure
Procedure DirEntryLastWriteTime()
FileTimeToLocalFileTime_(dirfile_\ftLastWritetime,dirfile_ft_)
FileTimeToSystemTime_(dirfile_ft_,dirfile_st_)
ProcedureReturn Date(dirfile_st_\wyear,dirfile_st_\wmonth,dirfile_st_\wday,dirfile_st_\whour,dirfile_st_\wminute,dirfile_st_\wsecond)
EndProcedure
Procedure DirEntrySize()
ProcedureReturn (dirfile_\nFileSizeHigh<<16+dirfile_\nFileSizeLow)
EndProcedure
One diffrent:
ExamineDir(dir$) need no search pattern and return a handle. If the handle<=0 then a error happend.
NextDirEntry(handle) need this handle.
Edit: DirEntryLastWriteTime() and the other Time-Function returns the Date in the Format of PB, so you can use FormatDate().
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Denis.
Hi GPI,
here's a procedure i used in an app.
The result is for exemple :
15/11/2003 15:08:32
There is 2 spaces between the date and the time.
If you want change this, it's this line :
ReturnString = ReturnString +" "+FileDateTime
The format of the date depends of this string :
Date.s="dd'/'MM'/'yyyy"
Take a look at API doc to another format.
This procedure give the local time format (we have it in France).
The procedure return a string with complete date and time format.
I used it in a listview to display date and time of files in current folder.
Hope it will help you.
Denis
Hi GPI,
here's a procedure i used in an app.
Code: Select all
Procedure.s GetFileTimeAndDate(AddrFiletime.l)
; AddrFiletime is a pointer of a WIN32_FIND_DATA structure
Date.s="dd'/'MM'/'yyyy"
FileDateTime.s=""
ReturnString.s=""
*FileInfos.WIN32_FIND_DATA = AddrFiletime
FileTimeToLocalFileTime_(*FileInfos\[url]mailto:ftLastWriteTime,@OutPut.l[/url])
FileTimeToSystemTime_(@[url]mailto:OutPut,@OutPutSystemTime.SYSTEMTIME[/url])
GetDateFormat_(2048,0,@OutPutSystemTime,@Date,@ReturnString ,254)
GetTimeFormat_(2048, #TIME_FORCE24HOURFORMAT ,@OutPutSystemTime,0,@FileDateTime,254)
ReturnString = ReturnString +" "+FileDateTime
ProcedureReturn ReturnString
EndProcedure
The result is for exemple :
15/11/2003 15:08:32
There is 2 spaces between the date and the time.
If you want change this, it's this line :
ReturnString = ReturnString +" "+FileDateTime
The format of the date depends of this string :
Date.s="dd'/'MM'/'yyyy"
Take a look at API doc to another format.
This procedure give the local time format (we have it in France).
The procedure return a string with complete date and time format.
I used it in a listview to display date and time of files in current folder.
Hope it will help you.
Denis

-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by GPI.
Thanks, but i found a solution
viewtopic.php?t=5270
GPI
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
Thanks, but i found a solution
viewtopic.php?t=5270
GPI
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
DirectoryEntryTime() is being severely missed here...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )