Change Directory as an Internal Command!

This is a discussion on Change Directory as an Internal Command! within the C Programming forums, part of the General Programming Boards category; Hello, Sorry to bother; however, I was wondering if anyone could assist me in code for a change directory function ...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    13

    Change Directory as an Internal Command!

    Hello,

    Sorry to bother; however, I was wondering if anyone could assist me in code for a change directory function as an internal command.

    Pretty much I am coding my own unix shell. I need to be able to internally code a 'cd' command to use in the syntax:

    cd <directory>

    If anyone can offer some insight I would be greatful!

    Thanks,

    slevytam

    ps. would the getcwd() function be able to keep track of these directory changes?

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,171
    man chdir
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    13
    thanks for your reply.

    chdir worked great!

    sorry to be a bother but I also need to do a dir function. is there a c function which will produce a directory listing?

    thanks,

    slevytam

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,171
    No. There are a set of functions that let you build your own though. You'll want to look at the man pages for opendir(), readdir(), and closedir().
    If you understand what you're doing, you're not learning anything.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    13
    ok thanks, ill take a look!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 11:43 AM
  2. type casting?
    By greatonesv in forum C Programming
    Replies: 12
    Last Post: 10-22-2008, 09:21 PM
  3. accessing all files in a folder.
    By pastitprogram in forum C++ Programming
    Replies: 15
    Last Post: 04-30-2008, 11:56 AM
  4. builtin command
    By jon21 in forum Linux Programming
    Replies: 1
    Last Post: 04-11-2002, 04:42 AM
  5. Replies: 2
    Last Post: 09-04-2001, 03:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21