V
V
Vitaly Pukhov2015-07-07 07:09:31
Programming
Vitaly Pukhov, 2015-07-07 07:09:31

Is it possible to "merge" two files without moving the data?

For one task, it was necessary to "connect" pieces of data, which are simple files (it does not matter in what form the data is in them) lying on a disk (fat32 or ntfs). The obvious way to connect is to append one file to another, but this requires moving data on the disk, which, in principle, is an extra step within the task, because. they both a priori lie on the same disk. As far as I remember, the FS stores, roughly speaking, information about where the file starts and how long it is, then each individual block from the file stores information about where the next one lies, that is, theoretically, for such a "connection" the last block in the first file is enough "associate" with the first block of the second file and change the information about the length of the first. But I can’t imagine how to implement this, do you have any ideas where you can dig?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tex0, 2015-07-07
@Neuroware

Think about the meaning of the concept of "disk defragmentation".
And as Hydro said above - you can't do that in YuzverMode. Should be done in KernelMode. Smoke towards the organization of data storage (file systems).

M
Mrrl, 2015-07-07
@Mrl

In any case, this requires that the length of the first file be a multiple of the cluster size. Then, if there is physical access to the disk, the chances may be non-zero.
If the files for the task were intermediate, then perhaps it would be easier to introduce an intermediate type - "multi-file file", which itself understands which file to read from. There it is necessary to override the ReadBytes () method (and all sorts of little things like Seek, Position, Length ...) At the same time, it can come in handy in other programs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question