Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 6th, 2005, 4:34 AM   #11
BungalowBill
Programmer
 
Join Date: Dec 2005
Posts: 40
Rep Power: 0 BungalowBill is on a distinguished road
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.
BungalowBill is offline   Reply With Quote
Old Dec 6th, 2005, 5:54 AM   #12
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Dec 6th, 2005, 6:41 AM   #13
BungalowBill
Programmer
 
Join Date: Dec 2005
Posts: 40
Rep Power: 0 BungalowBill is on a distinguished road
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.
BungalowBill is offline   Reply With Quote
Old Dec 6th, 2005, 10:11 AM   #14
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
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
nnxion is offline   Reply With Quote
Old Dec 6th, 2005, 12:33 PM   #15
BungalowBill
Programmer
 
Join Date: Dec 2005
Posts: 40
Rep Power: 0 BungalowBill is on a distinguished road
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)
BungalowBill is offline   Reply With Quote
Old Dec 6th, 2005, 1:23 PM   #16
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
There's already one - it's called fopen.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Dec 6th, 2005, 2:25 PM   #17
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
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
nnxion is offline   Reply With Quote
Old Dec 7th, 2005, 5:19 AM   #18
BungalowBill
Programmer
 
Join Date: Dec 2005
Posts: 40
Rep Power: 0 BungalowBill is on a distinguished road
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.
BungalowBill is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:11 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC