1

Topic: How to delete a file in With ++ without using remove ()

How to delete a file in With ++, without using f-tsiju remove () from standard Sishnoj  <stdio.h>?

2

Re: How to delete a file in With ++ without using remove ()

#include <stdlib.h>
system ("del file.txt");

3

Re: How to delete a file in With ++ without using remove ()

Dem_max , :-D  forgot about the such
And still it is possible:
- Specific OS f-tsijami,  DeleteFile () from WinAPI, or unlink from *nix
- To look, as remove was itself  from stdio
- asm (as a whole, concerns and first two points)
On  so it is possible

pushl filename;
call remove;
addl $4 %esp

Though, it is a pop-music on , many understand, why:blum3
PS
Dem_max though you know... Not, does not drive system () from stdlib, it is necessary absolutely without Sishnyh f-tsy
By the way, under Win if you  program MS  anyway remove () will cause NtDeleteFile () from Native API in the end that happens using GCC or other, I do not know:-D though probably, too most

4

Re: How to delete a file in With ++ without using remove ()

And generally!:-D If to dig further:
I can  remove () to a system call (0x2e or sysenter instructions)  ntdll! NtDeleteFile ()
If to look, kernel (), it would be necessary to get essence NtDeleteFile kernel debugger
More shortly ntdll.dll! NtDeleteFile () it is caused at remove () on Windows after MS  in the program
Unique part   f-tsii remove () are everyones SYSCALL/SYSENTER instructions which are dependent on OS, and at everyone the, but it certainly is already far, both from Si, and from Si ++
But it I so on Windows rummaged a little, in *nix unlink () it will be necessary to dig:crazy
For  boost it is possible so to show off:

boost:: filesystem:: remove ()

However, it causes in Boost or the same remove () from stdio, or any SYSCALL/SYSENTER at once without a call f-tsii stdio or is exact also , as remove () with call NtDeleteFile () at once

5

Re: How to delete a file in With ++ without using remove ()

magesi, 6/28/2012, 22:14, post2501197 wrote:

it causes in Boost or the same remove () from stdio

It agree   , for  are used WINAPI, for POSIX - remove ()

6

Re: How to delete a file in With ++ without using remove ()

boostcoder, 28.6.2012, 22:32 wrote:

magesi, 6/28/2012, 22:14, post2501197 wrote:

it causes in Boost or the same remove () from stdio

It agree   , for  are used WINAPI, for POSIX - remove ()

POSIX, not POSIX all the same all to syscall is reduced:-D which defined on certain system, i.e. a complete dependence
And everyones POSIX/not-POSIX calls, it no more, than a format/way of a call defined syscall on defined OS and no more
[mergetime] 1340913043 [/mergetime]
But generally, if even more deeply to dig, it depends on possibilities for operation which give first of all pieces of iron, and then developers of OS select what to use. For example, they can syscall create the same (i.e. as it )  page faults.
I.e.  parameters in special storage areas and as from kernel intercepts access to it...:crazy ... , I will follow whisky

7

Re: How to delete a file in With ++ without using remove ()

magesi, 6/28/2012, 22:36, post2501204 wrote:

But generally if even more deeply to dig, it depends on possibilities for operation which give first of all pieces of iron

How I understood, you conceived to delete a file, passing ?
In that case, to fall to level of pieces of iron it is not necessary. It is necessary to level of formats.
The approximate circuit of actions:
1. To clarify a format. Possible formats a coach and the whole cart: FAT12, FAT16, FAT32, NTFS *, in : ext2, ext3, ext4, XFS, JFS, ReiserFS and from tens) and it only the most widespread.
2. To study this format (by the way the information is far not on all formats, for example  do not publish .  on NTFS. There is a truth  the information, but it is extracted at random and  that is why it is unreliable, and probably does not support new versions)
3. To receive access rights to a disk on a low level.
4. To jam necessary , in the necessary sector. (Using the information extracted in 2 point)
:smile

8

Re: How to delete a file in With ++ without using remove ()

volatile, 6/29/2012, 00:08, post2501227 wrote:

As I understood, you conceived to delete a file, passing ?

Passing  from :-D

volatile, 6/29/2012, 00:08, post2501227 wrote:

As I understood, you conceived to delete a file, passing ?

As a whole, already "yes" smile but initially I searched for a method to delete a file means of Si ++ without using purely  f-tsii, and as a result came to it smile

9

Re: How to delete a file in With ++ without using remove ()

As that strange argue
We have
Program on With-> libc-> system -> the driver of devices-> iron
What to delete imperceptibly for OS a file it is necessary passing all this chain "agrees" with iron
For this purpose it is necessary to fulfill all that 3 points
1) Root
2) Knowledge FS on which we want to delete a file
3) The  for operation with HD

10

Re: How to delete a file in With ++ without using remove ()

If the purpose in that OS did not inform somebody that the file - is remote, in my opinion, it is necessary  driver FS and to say to nobody that you deleted a file. Removal through iron - the bad idea. It is possible to kill easily all FS. And in tables FS OS which in storage, the file as a result can remain.

11

Re: How to delete a file in With ++ without using remove ()

500mhz, 6/29/2012, 12:19, post2501320 wrote:

As that strange argue

Select was specific a strangeness place, differently

12

Re: How to delete a file in With ++ without using remove ()

H'm. It is possible to take an adjacent file from the same device (with the necessary access rights) to make to it move on our name, and then reverse move, recovering it an initiating name...