Page 1 of 1
EXTENSIONS IN MY OS
Posted: Fri Apr 23, 2004 2:40 am
by nuno_silva_pt
Can anyone please tell me how i can make a OS recognize the extension (APP) as an executable?
Re:EXTENSIONS IN MY OS
Posted: Fri Apr 23, 2004 4:31 am
by Pype.Clicker
you mean something like when typing "edit" at a shell, the system will know that it should execute "edit.app" ?
Most systems use the notion of PATH variable, which gives the shell a list of directories where programs may exists. if you're requested to execute "edit", your shell will
Code: Select all
foreach $directory in (PATH) {
if ($command.app in $directory) {
$program = $directory/$command.app;
break;
}
}
if (!$program) complain("command not found");
else exec($program);
Note that under unix, this is preferred to be a 'access right bit' rather than an extension prefix. Wheter one or the other is selected is simply a matter of taste, but i guess the 'executable bit' is easier to program with ... Making it a part of the filename is somehow ... hackish imho ...
Now maybe your question is rather "how can i load the .APP file in memory so that i can execute it" ? ... in which case reading "Linkers and Loader" e-book will certainly be a wise idea
Re:EXTENSIONS IN MY OS
Posted: Sat Apr 24, 2004 3:50 am
by nuno_silva_pt
Pype.Clicker wrote:
you mean something like when typing "edit" at a shell, the system will know that it should execute "edit.app" ?
That's not quite that.
Pype.Clicker wrote:
Now maybe your question is rather "how can i load the .APP file in memory so that i can execute it" ? ... in which case reading "Linkers and Loader" e-book will certainly be a wise idea
Yes, that is the question!
Pype.Clicker wrote:
Most systems use the notion of PATH variable, which gives the shell a list of directories where programs may exists. if you're requested to execute "edit", your shell will
Code: Select all
foreach $directory in (PATH) {
if ($command.app in $directory) {
$program = $directory/$command.app;
break;
}
}
if (!$program) complain("command not found");
else exec($program);
Can you write that in c please?
Thank you for your help!
Re:EXTENSIONS IN MY OS
Posted: Sat Apr 24, 2004 11:55 am
by proxy
no offense, but you really should be able to convert psuedo code to C code (especially somthing that simple).
Anyway, it wont translate directly to C because he is using the notion of "foreach" which basically says give me an iterator for each item in this container. C has no containers, and even if we assume it is a struct or somthing, you'd have to make many assumptions on the organization of the data. His code was simply a demonstration of the concept. FInally the line:
is going to to be very dependant on YOUR particular file system implementation.
good luck, but I recomend you do a bit mroe reading and general C programming before diving into an OS, it is not for the faint hearterd.
If I am wrong about your experience, then I appologize and once again, good luck.
proxy
Re:EXTENSIONS IN MY OS
Posted: Sun Apr 25, 2004 2:36 pm
by Pype.Clicker
no. i cannot ... actually, i can, but only if you have the same C library which i assume you have, which is probably not the case. So my C code would be useless and more difficult to understand.