Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,672 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,173 people online right now. Registration is fast and FREE... Join Now!




Replacing a file in a read only drive with C/C++

 
Reply to this topicStart new topic

Replacing a file in a read only drive with C/C++, I want to replace a file on read only drive

blueparukia
post 21 Jul, 2007 - 09:32 PM
Post #1


New D.I.C Head

*
Joined: 21 Jul, 2007
Posts: 4


My Contributions


Now, I know you say you will not do my homework, well, this is not homework, but I still have no idea what I'm doing.

I have tried this in VB and in Batch, and C++ is the only language I can think of that may be able to do this. (Batch probably can, but I don't know it properly).

On my friends computer, he has a read only drive, (X:\) with a .kix file on there. Well, he wants to modify the file so it logs his brothers movements on the PC. I programmed that with KIXtart, but now we need to replace the file. As the drive is read only, I can't do it. I have the replacement on my USB drive (F:\)


So if anyone who knows C or C++ could make a file that will do it, I would be greatly appreciative.

I want to replace X:\stu\student.kix with F:\student.kix


Also, if you think this belongs elsewhere, mods fell free to move.


Thanks


BP



User is offlineProfile CardPM

Go to the top of the page

MorphiusFaydal
post 21 Jul, 2007 - 11:21 PM
Post #2


D.I.C Lover

Group Icon
Joined: 12 May, 2005
Posts: 1,086



Thanked 8 times

Expert In: Hardware, Networking

My Contributions


QUOTE(blueparukia @ 21 Jul, 2007 - 10:32 PM) *

Now, I know you say you will not do my homework, well, this is not homework, but I still have no idea what I'm doing.

I have tried this in VB and in Batch, and C++ is the only language I can think of that may be able to do this. (Batch probably can, but I don't know it properly).

On my friends computer, he has a read only drive, (X:\) with a .kix file on there. Well, he wants to modify the file so it logs his brothers movements on the PC. I programmed that with KIXtart, but now we need to replace the file. As the drive is read only, I can't do it. I have the replacement on my USB drive (F:\)


So if anyone who knows C or C++ could make a file that will do it, I would be greatly appreciative.

I want to replace X:\stu\student.kix with F:\student.kix


Also, if you think this belongs elsewhere, mods fell free to move.


Thanks


BP



Short answer: YOU CAN'T.

Long answer: The filesystem is locked by the OS. It will not let you write to that drive under any circumstances. What you can try and do is write a program that writes the log to the file, and only makes the FS appear read only. Of course, to make the illusion work, you'll have to write the program to prohibit every other program on his PC from writing to it either. And even then... The OS might still freak on you.
User is offlineProfile CardPM

Go to the top of the page

blueparukia
post 21 Jul, 2007 - 11:29 PM
Post #3


New D.I.C Head

*
Joined: 21 Jul, 2007
Posts: 4


My Contributions


Oops, is just a read only file, not drive. And there should be a way to replace it then.....

If theres not, damn
User is offlineProfile CardPM

Go to the top of the page

no2pencil
post 21 Jul, 2007 - 11:31 PM
Post #4


My fridge be runnin OH NOEZ!

Group Icon
Joined: 10 May, 2007
Posts: 6,354



Thanked 58 times

Dream Kudos: 2375

Expert In: Goofing Off

My Contributions


QUOTE(blueparukia @ 22 Jul, 2007 - 12:29 AM) *

Oops, is just a read only file, not drive. And there should be a way to replace it then.....

If theres not, damn

If only the file is ready, move the file to a differnt file (basicly renaming it) then recreate the file.

CODE

move X:\file1 X:\file2
echo "gibberish" > X:\file1
User is offlineProfile CardPM

Go to the top of the page

blueparukia
post 21 Jul, 2007 - 11:33 PM
Post #5


New D.I.C Head

*
Joined: 21 Jul, 2007
Posts: 4


My Contributions


QUOTE(no2pencil @ 22 Jul, 2007 - 12:31 AM) *

QUOTE(blueparukia @ 22 Jul, 2007 - 12:29 AM) *

Oops, is just a read only file, not drive. And there should be a way to replace it then.....

If theres not, damn

If only the file is ready, move the file to a differnt file (basicly renaming it) then recreate the file.

CODE

move X:\file1 X:\file2
echo "gibberish" > X:\file1




Is that batch? And could this just be done if I booted in Linux??

Thanks,

BP
User is offlineProfile CardPM

Go to the top of the page

no2pencil
post 21 Jul, 2007 - 11:51 PM
Post #6


My fridge be runnin OH NOEZ!

Group Icon
Joined: 10 May, 2007
Posts: 6,354



Thanked 58 times

Dream Kudos: 2375

Expert In: Goofing Off

My Contributions


QUOTE(blueparukia @ 22 Jul, 2007 - 12:33 AM) *

Is that batch? And could this just be done if I booted in Linux??

Under Linux use :
CODE

mv /mnt/drive/file /mnt/drive/file2
echo "gibberish" > /mnt/drive/file
ls -l /mnt/drive/file

or even easier, if the file is readonly on a Linux system, just change the file properties.

User is offlineProfile CardPM

Go to the top of the page

blueparukia
post 21 Jul, 2007 - 11:55 PM
Post #7


New D.I.C Head

*
Joined: 21 Jul, 2007
Posts: 4


My Contributions


OK, thank you all
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 06:11AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month