EXTENSIONS IN MY OS

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
nuno_silva_pt

EXTENSIONS IN MY OS

Post by nuno_silva_pt »

Can anyone please tell me how i can make a OS recognize the extension (APP) as an executable?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:EXTENSIONS IN MY OS

Post 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 :)
nuno_silva_pt

Re:EXTENSIONS IN MY OS

Post 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!
proxy

Re:EXTENSIONS IN MY OS

Post 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:

Code: Select all

if ($command.app in $directory) {
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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:EXTENSIONS IN MY OS

Post 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.
Post Reply