Home AMX User Forum NetLinx Studio

How to get Date and Time of files in Flash

Hi,
I was wondering if it is possible to find the date and time of a file that I have created in flash.

I save configuration information into a file. This can be edited via FTP. This all works.
I need a way for my program to know when the file date and time changes in order to update my code with the new configuration information.

Would any one know of a way?

Regards
Craig

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    cmatkin wrote:
    I was wondering if it is possible to find the date and time of a file that I have created in flash.
    No, you can?t retrieve any file attributes via code. Bummer I know. :(
    cmatkin wrote:
    I save configuration information into a file. This can be edited via FTP. This all works. I need a way for my program to know when the file date and time changes in order to update my code with the new configuration information.

    Would any one know of a way?
    One possible workaround is to have the person who is editing the config file also drop another file (maybe something like reread.txt ? it doesn?t matter what?s in the file) in the same directory as a flag to indicate the config file needs to be re-read. Then your program can periodically do a FILE_DIR to see if the reread flag file exists and if it does your program can re-read the config file and then delete the reread flag file.
  • cmatkincmatkin Posts: 86
    Joe,
    thanks for that. I thought the same. It is not a nice solution though.
    The other solution that i thought of was sequence numbers.
    EG:
    every few seconds read a number from the bottom of the file.
    compare it to the sequence number stored in ram, if they are the same add 1 to the one in ram and update the one on the file.
    If the numbers are not the same then load the file and reset the numbers.

    My thought that is some one was editing the file the sequence number would get out of sync.

    Regards
    Craig
  • Joe HebertJoe Hebert Posts: 2,159
    cmatkin wrote:
    I thought the same. It is not a nice solution though.
    Okay, then how about telneting in after editing the file and pulsing a channel on a virtual device to flag your program to re-read the file.
    cmatkin wrote:
    The other solution that i thought of was sequence numbers? My thought that is some one was editing the file the sequence number would get out of sync.
    Yeah, that?s even worse then the first idea. :D All you need is a binary flag. No need to count anything and complicate matters. All you need is yes or no.
  • DHawthorneDHawthorne Posts: 4,584
    It's a heck of a lot of work for something that ought to be built in <cough>, but you can open a TCP client and connect to your own master, then issue a "list" command and parse the results.
  • Chip MoodyChip Moody Posts: 727
    Or to expand on the "monitor the file" concept a bit, you could look for the existence of a file in an upload directory every now and then, and upon finding it - copy it to a different directory and delete the original. Then keep checking the upload directory now and then to see if it "reappears".

    I like the "Telnet into myself" approach as well, but I think this one might cut some overhead and might be easier to implement?

    - Chip
  • viningvining Posts: 4,368
    With FTP there is a DMTF command or something to that affect that will return the date time stamp of the file. I used this quite a lot in a module that checks a remote PC running a FileZilla server. I periodically check the files on the PC using the DMTF command and if the time stamp changes I download the new file.
  • ericmedleyericmedley Posts: 4,177
    vining wrote:
    With FTP there is a DMTF command or something to that affect that will return the date time stamp of the file. I used this quite a lot in a module that checks a remote PC running a FileZilla server. I periodically check the files on the PC using the DMTF command and if the time stamp changes I download the new file.

    I'm pulling this from my fractured memory...

    but won't the LIST (pathway)(filename) command just return info (including mod date) of a file?
  • viningvining Posts: 4,368
    I don't recall either what "list" returned but I think it's filename and file size or is that POP3 email talk.

    I pulled the function that uses that time date stamp command out of the module and it's actually "MDTM" not what I said previously.
    DEFINE_FUNCTION CHAR[50]fnFTPCheckAllFiles(INTEGER iCase,CHAR iServerMsg[])
    
         {
         stack_var integer nFBS ;
         
         if (iCase == 230)
    	  {
    	  cNP_CheckFileName = remove_string(cFTPModSFileName,';',1) ;
    	  nFBS =  find_string(cNP_CheckFileName,';',1) ;
    	  if (nFBS)
    	       {
    	       cNP_CheckFileName = get_buffer_string(cNP_CheckFileName,nFBS - 1) ;
    	       }
    	  }
         else if (iCase == 213 || iCase == 550)
    	  {
    	  send_string vdvFTPmoduleDiag,"'<:FILE_STATUS:>',cNP_CheckFileName,'<:L_Update:>',iServerMsg,13,10" ;
    	  cNP_CheckFileName = remove_string(cFTPModSFileName,';',1) ;
    	  nFBS =  find_string(cNP_CheckFileName,';',1) ;
    	  if (nFBS)
    	       {
    	       cNP_CheckFileName = get_buffer_string(cNP_CheckFileName,nFBS - 1) ;
    	       }
    	  }
         if (length_string(cNP_CheckFileName))
    	  {
    	  send_string dvFTPSourceLocalSock,"'MDTM ',cNP_CheckFileName,13,10" ;
    	  }
         RETURN cNP_CheckFileName ;
         }
    
  • viningvining Posts: 4,368
    I just went to the NI's FTP server through commanfd line and it doesn't appear to support the MDTM command and a LIST command doesn't appear either. I believe I've only used the MDTM command on a FileZilla server which supports it. Never had a need to do it the other way around. You could just keep track of your files. With the module I use when I do the MDTM query I store the values in a structure for later comparison. When you download or transfer a file just track the file name and create your own date time stamp.

    link to commands:
    http://www.nsftools.com/tips/MSFTP.htm
  • dir will provide a list of files for the current directory. However, when I do this with Windows FTP some of the dates show up like:

    June 7 2006

    with no time listed, and others will display as:

    June 25 09:50

    with no year listed.

    However, if I use FTPSurfer (a freeware program I picked up somewhere) or Internet Explorer, it shows the file and directory names. If I right-click and select properties, it shows the complete date and time.
  • viningvining Posts: 4,368
    Yep, the "dir" command does return the date time of all files on the master in the directory specified. The attached is for the images directory on my NI-3100.
  • alexanboalexanbo Posts: 282
    cmatkin wrote:
    Hi,
    I was wondering if it is possible to find the date and time of a file that I have created in flash.

    I save configuration information into a file. This can be edited via FTP. This all works.
    I need a way for my program to know when the file date and time changes in order to update my code with the new configuration information.

    Would any one know of a way?

    Regards
    Craig

    The way I handle this, is to just put a button on the Touchpanel on my setup page that reloads the config info. Then teach the users if they change the config file they have to go press the button to actually load the info.
Sign In or Register to comment.