c++ - How to check if file is already opened using boost -


how check if file opened using boost if file not opened removed file other wise nothing

boost::filesystem::wpath file("c://test.txt");  if(boost::filesystem::exists(file)) {    if(here want check file open or not, if open run else)    {      boost::filesystem::remove(file);    }    else    {     } } 

it's job of os prevent/allow this.

each os has it's own ways of locking exclusive use, in case deletion fail anyways.

other oses (posix) unlink file entry inode, , file keeps remaining accessible processes have file opened. when last use of inode goes away, file deleted.

in short, don't try detect front, see whether deletion failed. otherwise you'll run race condition mentioned

how going deal situations, file opened in between check , attempt remove it? here

it seems have missed point of (seeing reply), , mike explained


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -