rename and swap folder names with windows server

Php, Divx, Apache, phpBB
Forum rules
Do not post any code that circumvents rules of any server. You are responsible for anything you use here.
Post Reply
darknkreepy3#
Site Admin
Posts: 247
Joined: Tue Oct 27, 2009 9:33 pm

rename and swap folder names with windows server

Post by darknkreepy3# »

An operating system needs time to finish a mechanical task that takes much more time then a line in a quickly executed scripting language like PHP. Sometimes in a windows server, you may ask a file to delete or folder to rename, so you can replace it onyl to find the delete went through ok, but the rename or move did'nt because your next line of execution asked to do something to a file or folder that hasn't finished being modified by the OS yet.

The answer in PHP is the usleep function. The format is usleep(*); where * is microseconds, not milliseconds as in flash actionscript 2, etc. Sometimes windows folder renaming works without this, unless you are flipping folders a-b and then you need to name a to a_temp and b to a, then a_temp to b. Inbetween you should give the computer a moment to do the mechanical task presently in rotating hard drive 5400-7200 rpm systems running multiple core motherboards with windows xp-vista-7. Sometimes when you're on a shared server, the lag is even worse in this process, even in linux, unix, etc, those shared servers are still susceptible to this problem. Use usleep(*);, you're not in that much of a rush, are you?

Image
Post Reply