Hi,
I am trying to develop a DOS-like system which will be able to do all minor functions like cd.. cd/ and changing to sub directories.

Guys I am stuck in how to find a single path for many files.....

Thanx in ADVANCE

Recommended Answers

All 6 Replies

Are you trying to emulate a DOS environment using C? Post the relevant code you have already, what it is supposed to do, and what it is doing wrong.

Are you trying to emulate a DOS environment using C? Post the relevant code you have already, what it is supposed to do, and what it is doing wrong.

yaa thats correct I need to emulate DOS environment in C.

I m yet to start the exact coding part
I am confused in system() function and windows.h files

I need to make a file which when executed must take you to the respective directory or sub directory of a given directory.

File Handling will be an alternative but I would have to make links to all ssub directories when I would like to access all of them one at a time.

This according to me requires handles not pointers.

I am confused in this concept!!

If you want to write your own mini-dos then you can not use the system() function for anything.

You can get list of files and sub-directories in MS-Windows by using the FindFirstFile() and FindNextFile() win32 api functions (look them up with google to find exact syntax.) You can find all sorts of examples on the net, just use google.

Are you trying to make a shell that will run ontop of windows executing windows/dos programs? Just keep track of your current directory youself in an extra variable. Example:

cd c:\myprogram

The current directory variable now holds: c:\myprogram\
(remember to check if it exsists)

main

Would first check to see if c:\myprogram\main.exe exsisted.
If it did, run system("c:\myprogram\main.exe");
if not, check to see if c:\dos\main.exe exsisted.
If it did, run system("c:\dos\main.exe");
If not, print "file could not be found."

dir

Will execute system("dir c:\myprogram\")

Hi,
I am trying to develop a DOS-like system which will be able to do all minor functions like cd.. cd/ and changing to sub directories.

Guys I am stuck in how to find a single path for many files.....

Thanx in ADVANCE

Well, if you are trying to executing those DOS command through your code. The only piece of work which you will have to do is to format the command and then look at the directory structure and then pass the formatted command to the system function. That should probably simulate all the simple commands that you want.

But then again, if your using the system function you haven't really achieved of anything writing your version of Windows DOS!

-ssharish

The problem with using the system() functions to do a lot of things is that whever you wanted it to do just disappears as soon as the system() function finishes. For example: lets say you want to change directories to c:\windows so you issue the command system(cd c:\\windows"); The system() function will execute the dos command, but as soon as system() returns to your program the program's current working directory will not have changed. To make such a command permanent in your program, it needs to issue equivalent C functions, in this case _chdir("c:\\windows");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.