unlink

Guaranteed file deletion upon program termination (C/C++)

Win32's CreateFile has FILE_FLAG_DELETE_ON_CLOSE, but I'm on Linux. I want to open a temporary file which will always be deleted upon program termination. I could understand that in the case of a program crash it may not be practical to guarantee this, but in any other case I'd like it to work. I know about RAII. I know about signals...

PHP: remove array element by element pointer (alias)

Is it possible to remove an array element by a pointer? Multidimensional array: $list = array( 1=>array( 2=>array('entry 1'), 3=>array('entry 2') ), 4=>'entry 3', 5=>array( 6=>array('entry 4') ) ); Reference array: $refs = array( 1=>&$list[1], 2=>&$list[1][2], 3=>&$li...

Why won't my php code "unlink" text files?

I have two text files, and a PHP script intended to delete them. My question is: why won't the two text files delete? They are both set to 777, maybe i should change permission settings? I think it's my webhost disallowing the function to execute... Here is my code: http://informationalinformation.info/fg/cron.php ...

Why can't I delete a file from a PHP daemon's child process?

I am building a simple PHP daemon script, using a php Daemon class provided at: http://www.phpclasses.org/browse/file/8958.html I'm stuck with this class for better or worse, and I don't have much time to get this done; so in order to issue custom commands to the daemon I'm just using a command file located in the /tmp directory. Howeve...

Delete the unwanted files and folders from destination folder as compared to source folder

I am using PHP and I need to script something like below: I have to compare two folder structure and with reference of source folder I want to delete all the files/folders present in other destination folder which do not exist in reference source folder, how could i do this? EDITED: $original = scan_dir_recursive('/v...

PHP unlink OR rewrite own/current file by itself

Hi Task: Cut or erase a file after first walk-through. i have an install file called "index.php" which creates another php file. <? /* here some code*/ $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "<?php \n echo 'hallo, *very very long text*'; \n ?>"; fwrite($fh, $stringData); /*herecut"/ /*here some code */ ...

PHP: deleting files – permission denied – chmod?

hi guys, i want to delete files from a directory via php. Somehow my php_errorlog always tells me: [06-Jun-2010 19:38:46] PHP Warning: chmod() [function.chmod]: Operation not permitted in /Users/myname/htdocs/ if ($_POST) { echo "yeah!!!"; print count($_POST['deletefiles']); chmod($path, 0777); //server ri...

how to change symlink target while preserving inode

Normally to change a symlink target one will first unlink the file and then re-creating the symlink with the new target path. However it will be assigned a new inode number. Maybe there is a private Mac api with an update_target_for_symlink() function, so the inode can stay the same? In case you wonder what I need it for.. a file mana...

How to avoid UNLINK security risks in PHP?

I'm using UNLINK with PHP and AJAX. I know that in this way is very dangerous, because everyone can delete any files. But I need to use AJAX because I can't reload the page when I delete the files. So how should I do to allow to delete the file only for the user who owns it? Please let me know other things too if you think I'm doing h...

Delete files then directory | PHP

I have this so far: <?php $path = "files/"; $files = glob("" . $path . "{*.jpg,*.gif,*.png}", GLOB_BRACE); $i = 0; foreach($files as $file) { $delete = unlink($file); if($delete) { echo $file . " deleted!<br />"; $i - 1; } else { echo $file . " could not be deleted...<br />"; ...