English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am trying to write an application for Mac OS X that will modify the /etc/hosts file. It is responsible for mapping IP addresses to domain names. When I use the fopen command with the directory as /etc/hosts, nothing happens. Yet when I made this application for windows, I could point directly to the file, c:/WINDOWS/system32/drivers/etc/hosts, it works fine. Do I need to use a different command, other than fopen, or do I need to be more specific in directing the application to the file. Do hard drives have letter names in OS X like they do in windows?

2006-07-26 15:03:32 · 2 answers · asked by powwow366 2 in Computers & Internet Programming & Design

I wish people would read the whole question. I need to know how to refer to it using C and the command fopen. Not how to do it in unix, I already know that...

2006-07-26 20:08:01 · update #1

2 answers

Did you check the permission of the file? Usually, files in /etc directories are restricted for Write for root user only.

In OS X or in any UNIX operating systems, drives (hardware) has a name in /dev directory. But they are accessed by mounting it to a place somewhere at or under root, then cd into it.

2006-07-26 15:09:31 · answer #1 · answered by tkquestion 7 · 0 1

Opening files in OS X is eactly the same as in UNIX or Linux. And unless you machine is different, the default permission on /etc/hosts in OS X is 644 so specifying the path "/etc/hosts" should work.

Though the mode when you open the file should be read only "r". There are other UNIX specific file reading functions.

2006-07-26 22:46:42 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers