file date and time - how to set

file date and time - how to set

Postby Otto » Fri Feb 21, 2020 8:50 am

Hello,
Can someone please help me out with the command for how to set file date and time.
Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6345
Joined: Fri Oct 07, 2005 7:07 pm

Re: file date and time - how to set

Postby karinha » Fri Feb 21, 2020 11:31 am

Master Otto, explain better what you need.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: file date and time - how to set

Postby Otto » Fri Feb 21, 2020 11:48 am

Hello João,
I want to copy files to a server.
The files on the server should have the same date time as the original file.

Thank you in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6345
Joined: Fri Oct 07, 2005 7:07 pm

Re: file date and time - how to set

Postby Otto » Fri Feb 21, 2020 11:56 am

Hello,
I think I found an example:


function setfiledate(cFile, dDate)

local hFile := FOpen( cFile, FO_READWRITE )
local aInfo

SET DATE FRENCH
SET CENTURY ON

SetFTime( hFile, "13:00:00", dDate )

// MsgInfo( "D o n e !" )

FClose( hFile )

return nil

I will test.
Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6345
Joined: Fri Oct 07, 2005 7:07 pm

Re: file date and time - how to set

Postby Otto » Fri Feb 21, 2020 11:58 am

There is a sample here:
C:\fwh\samples\testfdat.prg

Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6345
Joined: Fri Oct 07, 2005 7:07 pm

Re: file date and time - how to set

Postby karinha » Fri Feb 21, 2020 12:11 pm

Maybe... Go reporting.

Code: Select all  Expand view  RUN

#include "FiveWin.ch"
#include 'common.ch'

#define SW_HIDE 0
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_RESTORE 9

//------------------------------------*
// Deritrizes de fazer copia ou mover *
//------------------------------------*
#define FO_MOVE 0x0001
#define FO_COPY 0x0002
#define FO_DELETE 0x0003
#define FO_RENAME 0x0004
#define FOF_MULTIDESTFILES 0x0001
#define FOF_CONFIRMMOUSE 0x0002
#define FOF_SILENT 0x0004 // don't create progress/report
#define FOF_RENAMEONCOLLISION 0x0008

#define FOF_NOCONFIRMATION 0x0010 // Don't prompt the user.
#define FOF_WANTMAPPINGHANDLE 0x0020 // Fill in SHFILEOPSTRUCT.hNameMappings

// Must be freed using SHFreeNameMappings
#define FOF_ALLOWUNDO 0x0040
#define FOF_FILESONLY 0x0080 // on *.*, do only files
#define FOF_SIMPLEPROGRESS 0x0100 // means don't show names of files
#define FOF_NOCONFIRMMKDIR 0x0200 // don't confirm making any needed dirs
#define FOF_NOERRORUI 0x0400 // don't put up error UI
#define FOF_NOCOPYSECURITYATTRIBS 0x0800 // dont copy NT file Security Attributes
#define FOF_NORECURSION 0x1000 // don't recurse into directories.

//----------------------------> Copia o arquivo

FUNCTION execopia( warq, warq1 )

   warq1 := alltrim( warq1 )

RETURN SHFile( , FO_COPY , warq + Chr( 0 ) , warq1 )
 


Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: file date and time - how to set

Postby karinha » Fri Feb 21, 2020 12:17 pm

Go reporting...

Code: Select all  Expand view  RUN

#include "FiveWin.ch"

FUNCTION Main()

   local cBuffer  := Space( 12800 )
   local nBufSize := 12800

   hSource := FOpen( "Arquivo Original" )

   hTarget := FCreate( "Arquivo Copia" )

   While ( nBytes := FRead( hSource, @cBuffer, nBufSize ) ) > 0

      FWrite( hTarget, cBuffer, nBytes )

      SysRefresh()

   End

   FClose( hSource )

   FClose( hTarget )

   If File("Arquivo Copia")

   ...

   Endif

Return nil
 


Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: file date and time - how to set

Postby karinha » Fri Feb 21, 2020 12:29 pm

Code: Select all  Expand view  RUN

#include "FiveWin.ch"

FUNCTION Main()

   LOCAL cDirServ, cDirLocal, cArquivo

   cDirServ  := "\x_Archivos\"
   cDirLocal := "
E:\"
   cArquivo  := "
teste.txt"
 
   __CopyFile( cDirLocal+cArquivo, cDirServ+cArquivo+"
2" )

RETURN NIL
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: file date and time - how to set

Postby Otto » Fri Feb 21, 2020 12:30 pm

Hello João,
Thank you for your help.
I test with your code.
I map a drive on a web server with netDrive.
To synchronize data between my mod harbour web page and my desktop, I copy files like images, etc.
To keep traffic low, I would like to test it the file was changed (size, time, date) before I copy.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6345
Joined: Fri Oct 07, 2005 7:07 pm

Re: file date and time - how to set

Postby nageswaragunupudi » Fri Feb 21, 2020 12:35 pm

Mr. Otto.

This is the simplest and reliable function from (x)Harbour.
Code: Select all  Expand view  RUN

SetFDaTi( cFileName, dDate, cTime ) --> lSuccess
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10653
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: file date and time - how to set

Postby karinha » Fri Feb 21, 2020 12:49 pm

Master Rao, can you explain these commands please? I didn't find documentation.

Code: Select all  Expand view  RUN

   FileAttr()
   FileDate()
   FileTime()

   SetFAttr()
   SetFDaTi()
 


Many thanks.

Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: file date and time - how to set

Postby karinha » Fri Feb 21, 2020 12:52 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: file date and time - how to set

Postby Otto » Fri Feb 21, 2020 7:33 pm

Hello,
I did some more tests, but it seems as you can't change date/time stamp on these through netDrive3 (http://www.netdrive.net) mapped drives.
It is interesting that if I upload a file to my webserver - I have the same time setup as on the local server - I have a time difference of 1 hour.
Maybe this has to do with summertime.
I do some more tests.
Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6345
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 44 guests

cron