file date and time - how to set

Post Reply
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

file date and time - how to set

Post by Otto »

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

********************************************************************
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: file date and time - how to set

Post by karinha »

Master Otto, explain better what you need.

Regards, saludos.
João Santos - São Paulo - Brasil
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: file date and time - how to set

Post by Otto »

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

********************************************************************
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: file date and time - how to set

Post by Otto »

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

********************************************************************
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: file date and time - how to set

Post by Otto »

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

Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: file date and time - how to set

Post by karinha »

Maybe... Go reporting.

Code: Select all

#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
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: file date and time - how to set

Post by karinha »

Go reporting...

Code: Select all

#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
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: file date and time - how to set

Post by karinha »

Code: Select all

#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
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: file date and time - how to set

Post by Otto »

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

********************************************************************
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: file date and time - how to set

Post by nageswaragunupudi »

Mr. Otto.

This is the simplest and reliable function from (x)Harbour.

Code: Select all

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

G. N. Rao.
Hyderabad, India
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: file date and time - how to set

Post by karinha »

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

Code: Select all

   FileAttr()
   FileDate()
   FileTime()

   SetFAttr()
   SetFDaTi()
 
Many thanks.

Regards.
João Santos - São Paulo - Brasil
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: file date and time - how to set

Post by karinha »

João Santos - São Paulo - Brasil
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: file date and time - how to set

Post by Otto »

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

********************************************************************
Post Reply