----- Original Message ----- From: "Poon, Kelvin (Infomart)" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, February 24, 2003 11:03 Subject: File Manipulating Program
> Hi, > > I have a project at work that I need help on. I have came up with couple fo > problem in my program and was wondering if anyone could help me. Thanks a > lot. I really appreicate it. > > I have couple of questions regarding to my "file manipulating program". > > About the program: > > - There is an input folder and an output folder > - *.pdf files comes in the input folder waiting to be copied to the output > folder for printing > - only one pdf file is allowed to be in the output folder at one time > - my program has to check if there is any pdf files in the input folder and > if there is, check if there is any pdf file in the output folder and if > there isn't any move the pdf file to the output folder for print. This > program has to be running continously > - one point that is important to this program is that, the program needs to > check for the "Completeness" of the pdf files in the input folder. THe > reason is that when the pdf files get uploaded to the input folder, > sometimes it might not be "complete". The reason is, the moment you start > uploading a pdf file, you would be able to see that file in the input > folder, but it might not be fully uploaded yet (i.e. it might be empty). We > can't copy the file to the output folder yet if it is not completely > uploaded. > - lastly, when a pdf file is done printing in the OUTPUT FOLDER, it will be > removed automanticly. (which means my program doesn't have to worry about > that part) > > About the OS: > > - The OS is Win 2000 > > My design: > > Basically the structure of the loops in my program are the following: > > Loop1: > > If no *.pdf files in OUTPUT FOLDER > If there is *.pdf files in INPUT FOLDER > Go through each pdf file(s) in the INPUT FOLDER > If the pdf file is "complete" > Copy it to the OUTPUT FOLDER and rename it > to xxx.tmp > rename the xxx.tmp in OUTPUT FOLDER to > xxx.pdf > rename the xxx.pdf in INPUT FOLDER to > xxx.done > Go back to Loop1 > else > sleep for 15 sec > Go back to Loop 1 > else > sleep for 15 sec > Go back to Loop 1 > > > My questions: > > 1. As you can see, my program is going to be running infinitly. Will this > be a problem? I will probably make this program as a service on win 2000 so > it runs right awway when the computer is turned on. > > 2. When I check for the "completeness" for the pdf file. I was thinking of > trying to open it, if it fails therefore it is "incomplete". Since when the > file is uploading, the file is open for Write, and when a file is open for > Write, then I shouldn't be able to open it right? Am I right? > > > THank you very much, > > Kelvin Kelvin, I have several programs that do similar things. One checks an FTP directory for uploaded files, which can be uploading at the time the program checks for them. What I do is this: Locate the file Check the file's size and save it to a variable sleep for 5 seconds Check the file's size again and save it to another variable Compare the variables If they are the same, the file is complete (a reasonable assumption) If they do no equal, sleep and try again This is all placed inside of a loop. Your mileage may vary. Dirk Bremer - Systems Programmer II - ESS/AMS - NISC St. Peters USA Central Time Zone 636-922-9158 ext. 8652 fax 636-447-4471 [EMAIL PROTECTED] www.nisc.cc _______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
