Page 1 of 1
Concatinating a file in C (without stdio.h etc.)
Posted: Sat Mar 26, 2005 12:00 am
by JaMiE P
Hi all,
So yeah. Is it possible?
EDIT:Never mind. I'll just de-compile cat.
Re: Concatinating a file in C (without stdio.h etc.)
Posted: Sat Mar 26, 2005 12:00 am
by Da_Maestro
Perhaps you should elaborate more on your question. What is it exactly that you are trying to do?
Give us an example in C using stdio.h
Re: Concatinating a file in C (without stdio.h etc.)
Posted: Sat Mar 26, 2005 12:00 am
by carbonBased
There're tons of ways, assuming you've implemented some form of file i/o of your own, external to stdio.h.
Or, technically, you can just "extern" all the stdio functions, still use them, but not include stdio.h
Or, if you're really just looking for a C solution (and not an OSDev solution) then just exec a shell command of "cat file1 file2 > file3" or "copy file1+file2 file3" depending on your OS.
--Jeff
Re: Concatinating a file in C (without stdio.h etc.)
Posted: Sat Mar 26, 2005 12:00 am
by JaMiE P
I mean by creating a function/command that would concatinate (like most people's second program next to Hello World or the UNIX command cat) a file by using ASM, and then letting me call it from my program, like this (for an OS):
Part 1
Code: Select all
{
blah
blah
blah
f_concat("file.txt")
}
And then having this bit:
Code: Select all
unsigned int f_concat(char *message, unsigned int line)
{
I need the code which goes here
}
Thanks,
JaMiE P
Creator, Phelansys OS[/u]
Re: Concatinating a file in C (without stdio.h etc.)
Posted: Sun Mar 27, 2005 12:00 am
by carbonBased
The problem is (and what I was hinting at) is that if this is intended for a OS in development, you're going to need a basic kernel and IO driver/module before doing this, and even with both those, there is no standard way -- every OS is different.
That's the whole point of the libc and the stdio.h header file you mention. It provides a basic and portable way to do these things on all OSs. If you wish to circumvent this, then you're on your own. You'll need to look into the different devices you want to support (IDE? SCSI? ATAPI? etc) and write drivers for those, and some interface that will allow you do create such a 'cat'-like program.
Cheers,
Jeff
Re: Concatinating a file in C (without stdio.h etc.)
Posted: Mon Mar 28, 2005 12:00 am
by DruG5t0r3
again, those are OS dependant. Before implementing anything like that, you would need to design and code an IPC. doing stuff like cat bla | grep blah is done through pipes in linux I believe (correct me if i'm wrong)
Re: Concatinating a file in C (without stdio.h etc.)
Posted: Tue Mar 29, 2005 12:00 am
by [AlAdDiN]
if you are trying to write a concat function for your own OS, you have to write some I/O primitives first ...
assuming you have some functions that read file to a given memory addresse and write it from a given address, all you have to do is to copy both file in two memory adresses, create a new file and write the content of the two memory areas into it
but there is no "magic" methode to do it without any I/O methode