filetime and filedate in directory

This forum is for eXpress++ general support.
Message
Author
Victorio
Posts: 621
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

filetime and filedate in directory

#1 Post by Victorio »

Hi,
I have some little problem, need updated filetime and filedate of some file in directory.
functions filetime() and filedate() return still some time and date when program running, but I need info about access time
when other users write to this file.
This looks to fact, that when program is running, still see directory without changes in real time.
Test program attached.

Note : I need some system to control external programs called with Runshell. I am working on system which do this :
main program call external program with runshell
when external program start , create temporary file to hdd and write to it some row for example date and time of start process
every x seconds also fopen and fclose this file to "tell" main program, that, external process still running
when process pass, this temporary file will delete or write some row for example stop at date and time

main program waiting to end of external program, and every x seconds test if temporary file exist, when no, this looks external process is ended, when exist also look to last access date and time, and when this is more than some limit, for example 30 seconds, this looks, that external process have some problem, frozen, or crashed.

But when I can not determine real access time, this not work.

Maybe I have some wrong in my test program, but this looks to not refreshing Directory() structure when XPP program running. When close and open, date and time load correct.


Thanks for all advices
Attachments
TestFiledateFiletime.zip
(658.53 KiB) Downloaded 185 times

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: filetime and filedate in directory

#2 Post by Eugene Lutsenko »

Or maybe it's just when the process starts to create a file with the process ID, and when it ends to delete it?

Victorio
Posts: 621
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: filetime and filedate in directory

#3 Post by Victorio »

Hi Eugene,
I do not understand what do you mean ?
I have one main program, and this run via Runshell several exe modules, which run on all CPU cores simultaneously.
With Runshell have not any feedback. Tasklist is not usable because process can be frozen, and for it i use "timestamp" rows in temporary file.

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: filetime and filedate in directory

#4 Post by Auge_Ohr »

hi Victorio,
main program call external program with runshell
Runshell does not give you a Handle and so your "Problem" begin

this Code is using Ot4Xb and give you Information if you App is still running

Code: Select all

#include "ot4xb.ch"                                                                                   
// ---------------------------------------------------------------------------
proc main()
local oProcess := TRunProcess():New()
local lActive  := NIL
local dwExitCode

oProcess:cAppName := cPathCombine( GetWinDir(), "notepad.exe" )
// oProcess:cParams  := cPathCombine( cAppPath(), "TRunProcess.prg" )
// oProcess:lInheritHandles := .T.
oProcess:wShowWindow :=  oProcess:swMinimize
oProcess:lUseShowWindow := .T.
// oProcess:lCreateNewConsole := .F.
// oProcess:Cmd( "DIR > test.txt" )
if oProcess:Start()
   ? "Running " , oProcess:cAppName
   while oProcess:lTestActiveById()
     // App is running
   end
   ? "Exit Code: " , oProcess:GetExitCodeById()
you also can "Terminate" running App what this Demo Source show
TRunProcess.zip
(3.95 KiB) Downloaded 173 times
p.s. "switch" CPU before call TRunProcess() and Child App will run on that CPU even when MAIN "switch" again
greetings by OHR
Jimmy

Victorio
Posts: 621
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: filetime and filedate in directory

#5 Post by Victorio »

Thank you Jimmy, i will look to it, this can be very usable for me.
I am using also other system to controlling runshell processes with DBF file, where this external processes write information about status , and main program read it , in database is fields CPU01 to CPU12 for example. Main program determine number of cores , and run this number external modules, when all fields in DBF have status "passed" complete process is passed.
Problem is , when some of external process crashed, or frozen, then main program wait and wait... .

I will look, how can use TRunprocess.

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: filetime and filedate in directory

#6 Post by skiman »

Hi Victorio,

A solution can be to write the timestamp in the created files. If the file exists, you can check the content with a memoread. I suppose this is faster according to the directory() function.
In your main program, you can have an array which contains the time of your last check for each process. So you can check with the memoread for example each 5 seconds.
Best regards,

Chris.
www.aboservice.be

Victorio
Posts: 621
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: filetime and filedate in directory

#7 Post by Victorio »

Chris,
Yes, I am writing to file time stamp
first when begin is text START date time
when processing, every x seconds for example every minute write text ACTIVITY date time
and when process passed, write STOP date time

then when some problem I can look or program can read from this files info about time how long processes works, also when missing STOP, this is info that process crashed or cancelled by user

Victorio
Posts: 621
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: filetime and filedate in directory

#8 Post by Victorio »

Jimmy, please can you save attached file againg ? It cannot download, THX

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: filetime and filedate in directory

#9 Post by skiman »

Victorio,

So my suggestion is to read the content of the file to check if the process is still running instead of using the directory() function to check the time.
Best regards,

Chris.
www.aboservice.be

Victorio
Posts: 621
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: filetime and filedate in directory

#10 Post by Victorio »

Ok, Chris, i work on this variant.

Post Reply