![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Programmer
Join Date: Dec 2005
Posts: 40
Rep Power: 0
![]() |
Its cool, we all need help.
So whats the code for doing this?. If i wanted to set up the FAT. This is what i go so far. void format(){ int j; for(j=4; j<512; j++){ disk[1].FATdata[j] = unused; } int i; for(i=0;i<512; i++){ disk[2].FATdata[i] = unused; } disk[1].Datablock[0] = data; disk[1].FATblock[1] = FATdata; disk[1].FATdata[2] = FATdata; disk[1].Dirblock[3] = dirdata; disk[1].Datablock[79] = data; } I have data, FATdata, and dirdata declared in a separate header file like this:- typedef union Tdiskblock Diskblock; union Tdiskblock{ Datablock data; Dirblock dirdata; FATblock FATdata; }; but when i compile its saying that data, FATdata, and dirdata are not defined. BTW that 79 thing is just something extra i forgot to take out. Its saying that Datablock,Dirblock and FATblock are not members of Tdiskblock, but it looks like they are to me. If you haven't guessed, im a complete newbie with this so don't be too harsh. thanks Last edited by BungalowBill; Dec 6th, 2005 at 4:49 AM. |
|
|
|
|
|
#12 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Read the forum's FAQ/rules. Put your code inside code tags.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#13 |
|
Programmer
Join Date: Dec 2005
Posts: 40
Rep Power: 0
![]() |
sorry. will do next time. I have another question now though. If i had some data in a random block like:-
strcpy((char*)disk[79].data, "Tommorrow Never Knows"); how would i use fopen() to open this. I'm stumped. ![]() |
|
|
|
|
|
#14 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Your question stumped me
![]() But really, what is it you want to open?
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#15 |
|
Programmer
Join Date: Dec 2005
Posts: 40
Rep Power: 0
![]() |
If meant if i stored that on disk, that piece of text, how would i open it up - but don't worry, i got that sorted.
I figured out how to open that specific file, now all i have to do is write a generic method which opens any file i give to it in the parameters. like (const char * path, const char*mode) |
|
|
|
|
|
#16 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
There's already one - it's called fopen.
![]() |
|
|
|
|
|
#17 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
If you want to create fopen again, then note that fopen is a high level function. You would be wise to make a low level function (first).
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#18 |
|
Programmer
Join Date: Dec 2005
Posts: 40
Rep Power: 0
![]() |
I've got a piece of code for myfopen.
Myfile * myfopen(){
Myfile * file = (Myfile*) malloc(sizeof (Myfile));
memmove(file->buffer.data, disk[79].data, blocksize);
file->pos = 0;
return file;that gets whatever is in diskblock 79. How would i change that to make it get the data from any postion the user selects? i.e. Myfile * myfopen(const *char path, const char * mode){
Myfile * file = (Myfile*) malloc(sizeof (Myfile));
memmove(file->buffer.data, (path,mode) blocksize);
file->pos = 0;
return file;but that doesn't work. Does anyone know the answer to this? i need something instead of the bit in bold. Cheers for any help. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|