OK, so what I basically did was to reverse the read method.
In the main kernel file, I did a method which takes the file path from the user, and in the file system driver I created a method which does the writing. However, since I changed the fsys file (file system driver) both the read and write operations appear to be broken (Whenever I try to do one of these operations I get a bsod stating "Invalid op code").
Did someone got this error as well when trying to do such a thing?
Problem in writing to a text file
Moderator:Moderators
Re: Problem in writing to a text file
Hello,
There has been no known report of a similar error. If possible, providing the bochs crash log and the changed code might help in finding the cause of the error.
There has been no known report of a similar error. If possible, providing the bochs crash log and the changed code might help in finding the cause of the error.
Re: Problem in writing to a text file
That's the point, I always used VirtualBox to test the OS.
The code I created in fsys.cpp:
And I also changed in fsys.h:
That's all the code I created.. If I remove this code, everything goes back to normal and HeinanOS runs correctly.
The code I created in fsys.cpp:
Code: Select all
int volWriteFile(const char* filename, const char* DirectoryName, char* Buffer) {
// The const char* DirectoryName variable will receive the current directory
unsigned char device = 'a';
if(strcmp(filename, ":")){
device = filename[0];
filename += 3; //strip it from DirectoryName
}
//! Create the file here to give the internal program less complexity
FILE outfile;
int cur_char;
//! the the name to the new file's metadata
// outfile.name = filename;
outfile = volOpenFile(filename); // Append file
//! Handle an exception
if(outfile.currentCluster == 0){
//! This exception will occure if the FILE file cannot be saved
return 1; //! Fail.
}
//for (cur_char = 0; cur_char < 512; ++cur_char) {
// // This routine might be usefull if we parse the Buffer content and
//}
if (_FileSystems [device - 'a']) {
_FileSystems[device - 'a']->Write (outfile, DirectoryName, Buffer);
outfile.deviceID = device;
}
return 0;
}
Code: Select all
typedef struct _FILE_SYSTEM {
char Name [8];
FILE (*Directory) (const char* DirectoryName);
void (*Mount) ();
void (*Read) (PFILE file, unsigned char* Buffer, unsigned int Length);
void (*Write) (FILE file, const char* DirectoryName, char* Buffer);
void (*Close) (PFILE);
FILE (*Open) (const char* FileName);
}FILESYSTEM, *PFILESYSTEM;
Code: Select all
extern int volWriteFile(const char* filename, const char* DirectoryName, char* Buffer);