I am using rename function (C, under ubuntu) to move file from one folder to another when trying:
rename("./t2.c", "./this/then_this/it_works.c");
it works wonders, removes the file from current folder and moves it to the then_this folder under name.
but when i try this:
rename("./t2.c", "~/.local/share/Trash/files/it_works.c");
it just doesn't work, but in terminal typing in "cd ~/.local/share/Trash/files/it_works.c" does open the trash bin.
So what i'm trying to do is move a file to trash bin(delete it). Could anyone tell me what i am doing wrong?
The problem is that ~
only works in the shell. Replace with the full absolute path (e.g. /home/user1031204/.local/...
) & re-try.
realpath() will be helpful here. You may want to look at glob() and wordexp() as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With