| |

VerySource

 Forgot password?
 Register
Search
View: 2262|Reply: 15

How to insert a string at the beginning of the file?

[Copy link]

3

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-2-1 00:20:01
| Show all posts |Read mode
How to insert a string into a text file? Not covered!
Thank you!
Reply

Use magic Report

0

Threads

63

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-3-11 22:15:01
| Show all posts
I'm stupid, I just read the original first, and then ...
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 United States

Post time: 2020-3-20 12:00:01
| Show all posts
If the file size is hundreds of megabytes, isn't this method inefficient?
Reply

Use magic Report

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-3-20 15:45:01
| Show all posts
But if you do n’t do that, would n’t the person writing the file system driver cry to her mother?
Reply

Use magic Report

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-3-20 20:45:01
| Show all posts
Hehe, people who write file system drivers are not geniuses, they are also programmers like us, and we think they are very complicated. They are the same.
Imagine if you let you design a disk format and implement a set of file system drivers on it. To support random insertion and deletion without moving any data, of course, you must also consider disk utilization and read efficiency. (Especially efficient sequential read)-Do you think this is feasible? :)
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-26 22:30:01
| Show all posts
I haven't written a file system, those people are very good programmers for me :)

I think if the file is large, efficiency is really an issue. In order to insert a few characters, it may take several minutes or even longer.
I think things can be done better, so come up with this concern
Reply

Use magic Report

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-3-29 03:15:01
| Show all posts
In some cases, people are really thinking of better ways, such as those for database systems.
But they are generally based on the same level of the file system and then encapsulate their own layer of a more abstract logical file format to achieve the purpose, such as dividing a file into pieces, putting a few bytes on each block header, and marking it. Is this piece still useful and where is the next piece?
But for ordinary occasions, this is not only tedious, but also not very beneficial in the matter, especially, you have to write, read, and assemble the program yourself, which is very troublesome.
If your file is a special binary file, it can be divided into fixed length records one by one, and if you are not afraid of trouble, you can also do this, hoho.
You can also consider using a B-tree, which is usually not necessary. :(
Reply

Use magic Report

0

Threads

55

Posts

44.00

Credits

Newbie

Rank: 1

Credits
44.00

 Invalid IP Address

Post time: 2020-3-30 09:30:01
| Show all posts
Fortunately, the landlord did not ask why the vector does not support push_front / pop_front.
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-3-31 12:00:01
| Show all posts
The question from the landlord reminded me of viking virus,
Also insert a paragraph at the beginning of the exe file,
Generate a virus file and the original exe file when executed, and some bats, and execute, while inserting the beginning of other exe

Have the opportunity to ask the virus author ^ _ ^
Reply

Use magic Report

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-4-1 20:30:01
| Show all posts
The exe seems to be a little better, sometimes there will be free bytes in front of it, and sometimes a jmp instruction can be inserted logically.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list