FTP FileDate ?

Just starting out? Need help? Post your questions and find answers here.
Thade
Enthusiast
Enthusiast
Posts: 266
Joined: Sun Aug 03, 2003 12:06 am
Location: Austria

FTP FileDate ?

Post by Thade »

Hello - after many years with no bugs I ran into one I guess - here's the topic :D

I have written an FTP Program for my special needs. What does not work is the filetime which I get

Code: Select all

MDate = FTPDirectoryEntryDate(FTP)
This produces rather rounded values

Postcard10c.jpg|1206338400|186673|24.03.2008 06:00:00|
Kopie von Postcard10c.jpg|1202623200|175930|10.02.2008 06:00:00|
Image2a.png|1206338400|265693|24.03.2008 06:00:00|
Image2.png|1202623200|162436|10.02.2008 06:00:00|
Image1a.png|1206338400|80214|24.03.2008 06:00:00|
Image10c.png|1206338400|429193|24.03.2008 06:00:00|
Image10a.png|1206338400|332372|24.03.2008 06:00:00|
Image1.psd|1202623200|1373386|10.02.2008 06:00:00|
Image1.png|1202623200|375143|10.02.2008 06:00:00|
gutar(Frame 9).gif|1198303200|95161|22.12.2007 06:00:00|
gutar(Frame 8).gif|1198303200|95244|22.12.2007 06:00:00|
gutar(Frame 7).gif|1198303200|95111|22.12.2007 06:00:00|
gutar(Frame 6).gif|1198303200|95158|22.12.2007 06:00:00|
gutar(Frame 5).gif|1198303200|95546|22.12.2007 06:00:00|
gutar(Frame 4).gif|1198303200|94927|22.12.2007 06:00:00|
gutar(Frame 3).gif|1198303200|95103|22.12.2007 06:00:00|
gutar(Frame 2).gif|1198303200|95093|22.12.2007 06:00:00|
gutar(Frame 17).gif|1198303200|95222|22.12.2007 06:00:00|
gutar(Frame 16).gif|1198303200|95196|22.12.2007 06:00:00|
gutar(Frame 15).gif|1198303200|95210|22.12.2007 06:00:00|
gutar(Frame 14).gif|1198303200|95162|22.12.2007 06:00:00|
gutar(Frame 13).gif|1198303200|95571|22.12.2007 06:00:00|
gutar(Frame 12).gif|1198303200|94938|22.12.2007 06:00:00|
gutar(Frame 11).gif|1198303200|95222|22.12.2007 06:00:00|
gutar(Frame 10).gif|1198303200|95110|22.12.2007 06:00:00|
gutar(Frame 1).gif|1198303200|95019|22.12.2007 06:00:00|

Code: Select all

						If NextFTPDirectoryEntry(FTP)
							If FTPDirectoryEntryType(FTP) = 1 ; 1=File  2=Dir
								AddElement(FList())
								FTPii+1
								MDate=FTPDirectoryEntryDate(FTP)
								MDate+3600 * Val(GetGadgetText(ServerTimeAdd1)) ; the hours the servertime differs
								FList()=FTPDirectoryEntryName(FTP)+"|"+Str(MDate)+"|"+Str(FTPDirectoryEntrySize(FTP))+"|"+FormatDate("%dd.%mm.%yyyy %hh:%ii:%ss", MDate)+"|"
								Debug FList()
							EndIf
							If FTPDirectoryEntryType(FTP) = 2 ; 1=File  2=Dir
								FTPDii+1
								AddElement(DList())
								MDate=FTPDirectoryEntryDate(FTP)
								MDate+3600 * Val(GetGadgetText(ServerTimeAdd1)) ; the hours the servertime differs
								DList()=FTPDirectoryEntryName(FTP)+"|"+Str(MDate)+"||"+FormatDate("%dd.%mm.%yyyy %hh:%ii:%ss", MDate)+"|"
								Debug DList()
							EndIf
						Else
							Break
						EndIf
This is what it should look like:
Filename|date|size|formatted date|

Postcard10c.jpg|1206417899|186673|25.03.2008 04:04:59|
Kopie von Postcard10c.jpg|1202660770|175930|10.02.2008 16:26:10|
Image2a.png|1206417526|265693|25.03.2008 03:58:46|
Image2.png|1202660269|162436|10.02.2008 16:17:49|
Image1a.png|1206417509|80214|25.03.2008 03:58:29|
Image10c.png|1206417882|429193|25.03.2008 04:04:42|
Image10a.png|1206417799|332372|25.03.2008 04:03:19|
Image1.psd|1202660751|1373386|10.02.2008 16:25:51|
Image1.png|1202660277|375143|10.02.2008 16:17:57|
gutar(Frame 9).gif|1198381690|95161|23.12.2007 03:48:10|
gutar(Frame 8).gif|1198381674|95244|23.12.2007 03:47:54|
gutar(Frame 7).gif|1198381661|95111|23.12.2007 03:47:41|
gutar(Frame 6).gif|1198381653|95158|23.12.2007 03:47:33|
gutar(Frame 5).gif|1198381644|95546|23.12.2007 03:47:24|
gutar(Frame 4).gif|1198381635|94927|23.12.2007 03:47:15|
gutar(Frame 3).gif|1198381628|95103|23.12.2007 03:47:08|
gutar(Frame 2).gif|1198381619|95093|23.12.2007 03:46:59|
gutar(Frame 17).gif|1198381760|95222|23.12.2007 03:49:20|
gutar(Frame 16).gif|1198381753|95196|23.12.2007 03:49:13|
gutar(Frame 15).gif|1198381745|95210|23.12.2007 03:49:05|
gutar(Frame 14).gif|1198381736|95162|23.12.2007 03:48:56|
gutar(Frame 13).gif|1198381729|95571|23.12.2007 03:48:49|
gutar(Frame 12).gif|1198381720|94938|23.12.2007 03:48:40|
gutar(Frame 11).gif|1198381710|95222|23.12.2007 03:48:30|
gutar(Frame 10).gif|1198381699|95110|23.12.2007 03:48:19|
gutar(Frame 1).gif|1198381546|95019|23.12.2007 03:45:46|

I want to have a 100 % mirror Server - PC
So it is important, that the dates are exact the same.
The FTP commandset of PureBasic misses SetFiledate on the server - so I quickly wrote a php program which fills that gap until I find a better solution
I send a file with a list (as seen above) with the exact dates together with the uploaded files and the php-program runs every 15 minutes (Scheduled Job) to look if there are files to have be corrected ...

Anyway - WinSCP shows on the second exact dates, my php programs show the exact dates - only PureBasic does not - is my program wrong? Or did no-one notice that bug before?

Have a nice day everybody
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: FTP FileDate ?

Post by Marc56us »

Hi,

Hasn't the operating system or FTP server software version or configuration been changed in the meantime?

When I do PB application tests to a Windows server (FileZilla Server) the timestamp is wrong or at zero while to an un*x server (Linux with VsFTPd server) the same program displays the dates correctly.
On ftp windows, files at root have date OK, but at 00:00:00 if change dir (SetFTPDirectory()) (OK if with another FTP software)

See PB help for ExamineFTPDirectory()

'Remarks
For now, only Unix-like servers are supported for directory listing. The FTP protocol doesn't specify how a directory listing has to be returned, so every server has its own way to returns the directory information. Fortunately, most of the world servers are running under Unix/Linux and uses the same way to return the data. That said, there is no warranty that the listing works on every servers. This command will be updated on demand to automatically handle more servers type. If the server isn't supported, please use FTPDirectoryEntryRaw() to get back the raw information about each entry.
'

:wink:
Thade
Enthusiast
Enthusiast
Posts: 266
Joined: Sun Aug 03, 2003 12:06 am
Location: Austria

Re: FTP FileDate ?

Post by Thade »

Thank you for the answer.
Interesting stuff.

Anyway - I figured out a "better" solution :)

Meanwhile I rewrote my PB-ftp-program, ported it to complete to php.
Has many advantages.
Sends and receives files by submitting the same paths as on the local Mirror-PC. Adds missing directories without moving through the filesystem.
The filedates work and I have touch($path.$file, $filedate1, $filedate2) to set the exact mirror dates as needed.

Doesn't look as nice yet - before I had 8 windows popping up showing the state (when I sent 1000 files) on the progressbars. :D
Maybe I will add a javascript snippet to simulate that on the workpage.

Ok that was just for info - has nothing lost in a PureBasic Forum :wink:
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Post Reply