Questions tagged [unlink]

Refers to removing a file from a filesystem.

This tag is appropriate for questions about deleting a file from a filesystem whether by using a language-specific function such as Perl or PHP's unlink or by making a system call such as Unix's unlink.

Wikipedia has more information about unlink.

526 questions
5
votes
5 answers

PHP unlink symlink

when I create under windows a symlink (didn't test it yet under linux) and want to delete/unlink it again (I tried it with the unlink() - function), it always delete the symlink + original file. But I just want to delete the symlink. Isn't there any…
user1323512
  • 137
  • 1
  • 2
  • 8
4
votes
1 answer

Deleting subdirectories and files in a given directory

I want to delete all subdirectories and files from a directory, but not the directory itself. For examnple, if I pass "Sample" directory in a variable, and "Sample" directory contains three subdirectories and 3 files, I want to delete all that 3…
Shaggy
  • 111
  • 1
  • 5
  • 11
4
votes
2 answers

How to unlink() by its name without knowing the file extention?

In short We have a a file called clients.(unique parameter). And now we want to unlink() it, but as we don't know the file extension, how do we succeed? Longer story I have a cache system, where the DB query in md5() is the filename and the cache…
Kalle H. Väravas
  • 3,579
  • 4
  • 30
  • 47
4
votes
5 answers

how to delete a single line in a txt file with php

i was wondering if it is posible to delete a single line in a txt file with php. I am storing emailadresses in a flat txt file named databse-email.txt I use this code for it:
Jack Maessen
  • 1,780
  • 4
  • 19
  • 51
4
votes
4 answers

Recursive delete

I have this code to recursive delete files and directories. It works fine but has a little problem. If $path = /var/www/foo/ it will delete everything inside of foo, but not foo. I want to delete foo directory too. Any idea? public function…
thom
  • 41
  • 1
  • 2
4
votes
1 answer

Remove a directory in R invoking linux commands

I am writing code using R that invokes Linux commands to create a directory with multiple files which has to be deleted at the end. I tried using file.remove(directory_name) which removed the directory only when its empty. If the directory has…
amc794
  • 65
  • 6
4
votes
1 answer

why system call unlink so slow?

#include #include void dump_log(int size){ char cmd[1024]; snprintf(cmd, sizeof(cmd)/sizeof(cmd[0]), "dd if=/dev/zero of=from.bin bs=1024 count=%d", size); int ret = system(cmd); if (ret<0){ …
zzn
  • 2,376
  • 16
  • 30
4
votes
3 answers

How to unlink an app from Admob

Im starting to develop android applications, and I recently uploaded an app to the Play Store. In my admob account, i accidentally created 2 apps with the same name. Turns out that i linked the wrong app to my real app. Although, i was pretty sure…
GUZI_UY
  • 93
  • 1
  • 9
4
votes
2 answers

PHP: Safe way to remove a directory?

Consider this code: public static function removeDir($src) { if (is_dir($src)) { $dir = @opendir($src); if ($dir === false) return; while(($file = readdir($dir)) !== false) { if ($file != '.' &&…
Dalius
  • 726
  • 1
  • 8
  • 19
4
votes
0 answers

Is there any difference between unlink() and remove() on a file?

In C++ on Linux I see that on the man page for remove() it states in part: remove deletes a name from the filesystem. It calls unlink for files, and rmdir for directories. So I'm wondering if there is any difference between calling remove()…
WilliamKF
  • 41,123
  • 68
  • 193
  • 295
4
votes
2 answers

unlink cannot delete file

I'm frustrated about deleting file in ubuntu using PHP unlink(). I created a very simple simulation as follow: create a folder named "files" beneath /var/www with 766 permission. upload a file, let say "image.png" in that folder & set the…
user1134475
  • 415
  • 1
  • 8
  • 18
4
votes
6 answers

Delete file onclick with PHP

I want to delete a file when a user clicks on a delete link. But when I go to my page, the file gets deleted and I don't know why: echo '

Delete Now!

'; What am I doing wrong?
Code Lover
  • 8,099
  • 20
  • 84
  • 154
4
votes
4 answers

Php unlink() function and cyrillic

I have a problem with deleting files through unlink() function. When the file is with a cyrillic name the function doesn't work. [24-Jul-2012 00:33:35 UTC] PHP Warning: unlink(/home/gtsvetan/public_html/мениджър.doc) [function.unlink]: No such…
user546774
3
votes
0 answers

Problem with unlinking file in case sensitive system

I have a function that i'm running on my windows against case sensitive remote server (SMB). The function creates two files: "fileA", "FILEa". When i'm trying to unlink the file "fileA" both of my files disappear from the folder. Right after that…
Eig
  • 31
  • 2
3
votes
2 answers

Why does Unlink not work on this script?

What you see below is a part of my script. The problem is that I need only the re-sized thumb image and not the original file. The image won't re-size if it is not uploaded, therefore the process should look like this: -> creates a folder ->…
faq
  • 2,965
  • 5
  • 27
  • 35