LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-04-2003, 07:47 AM   #1
Prommy
LQ Newbie
 
Registered: Apr 2003
Location: Sweden
Distribution: Fedora
Posts: 10

Rep: Reputation: 0
File handling in Linux


Hi.
I'm quite new to Linux programming and is trying to do a little c program that involves some file handling. If I would like to do something like getting directory listings, moving files, etc. from my program, how is that done? Right now my program simply calls a bash script that does the file handling stuff, but that feels like just going round the problem.

I've searched all over the web with no result...

/Daniel
 
Old 07-04-2003, 09:09 AM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
why not look at the open close and stat system calls. also have you looked at the source for ls / mv / cp?
 
Old 07-04-2003, 09:19 AM   #3
Prommy
LQ Newbie
 
Registered: Apr 2003
Location: Sweden
Distribution: Fedora
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by kev82
Also have you looked at the source for ls / mv / cp?
Yes I have. Problem there is that it's quite much code to read through...

/Daniel
 
Old 07-04-2003, 09:39 AM   #4
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
ive just found this link it might help a bit

http://docs.linux.cz/c_marshall/node20.html
 
Old 07-04-2003, 10:01 AM   #5
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
Re: File handling in Linux

Quote:
Originally posted by Prommy
Right now my program simply calls a bash script that does the file handling stuff, but that feels like just going round the problem.
/Daniel
why? how many of your favorite programs rely on other, smaller programs to get the job done? what about programs like xcdroast, which are little more than just front ends to other programs (cdrecord in this case)? the whole *NIX deal is not re-invent the wheel. if it's there (especially standard tools like ls and mv), use it. If a bash script feels crappy, use popen().
 
Old 07-20-2003, 10:05 AM   #6
jackyopensrc
LQ Newbie
 
Registered: Jul 2003
Location: Kuala Lumpur,Malaysia.
Distribution: Red Hat 7.3
Posts: 16

Rep: Reputation: 0
My program encounter error with the header file #include<fcnt1.h>

Some document states that this header file which is to handle some
files-handling.

Please give me the advise! Thanks you !
 
Old 07-20-2003, 10:37 AM   #7
coolman0stress
Member
 
Registered: Jun 2003
Location: Toronto, Ontario, Canada
Posts: 288

Rep: Reputation: 30
If it's the same library i think it is then it's <fcntl.h> with an l and not a 1.

If C filehandling doesn't work for you, you might want to check out Perl's, it's basically the same thing, but a bit simpler (i found). You also use fcntl in Perl
 
Old 07-21-2003, 01:16 AM   #8
jackyopensrc
LQ Newbie
 
Registered: Jul 2003
Location: Kuala Lumpur,Malaysia.
Distribution: Red Hat 7.3
Posts: 16

Rep: Reputation: 0
File handling in Linux!

Thanks Prommy,

You're right !It's fcntl.h !

I will continue this program because I am not very fimilar with Perl programming.

Thank you for guidances!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
linux file handling errors class_struggle Linux - Newbie 1 07-26-2004 05:31 PM
c file handling on linux suchi_s Programming 5 06-23-2004 09:01 AM
c file handling on linux suchi_s LQ Suggestions & Feedback 1 06-23-2004 01:48 AM
Screem file handling silmaril8n Linux - Software 1 06-14-2004 03:44 PM
file handling in c++ gtk+ alisha Programming 1 04-13-2004 12:22 PM


All times are GMT -5. The time now is 04:54 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration