1827791 Members
2794 Online
109969 Solutions
New Discussion

Re: Help Needed in C++

 
RobertClark
Occasional Contributor

Help Needed in C++

I want to impliment directory operation on C++ in unix.

A class that do directory operation, such as
1)remove directory
2)change directory.
3)copy directory.
4) remove directory.
5)remove file from directory
6)copy particular file from one directory to another directory.
7) is directory check :-whether directory is present.
8) move directory,if directory is not present.


Can somebody help me doing,or anyone has implemented library in C++ (Linux) please share.
6 REPLIES 6
Dennis Handly
Acclaimed Contributor

Re: Help Needed in C++

I'm not sure I see any particular need to do this with C++ classes. Except for something complex like remove directory (and contents).

Is there any objection to using system(3) for 3) and 4)?

(Is there a difference between 1) and 4)?)
RobertClark
Occasional Contributor

Re: Help Needed in C++

Well i dont want to use system call and passing argument., and 1 and 3 remain the same, its typo error.
Dennis Handly
Acclaimed Contributor

Re: Help Needed in C++

>Well i dont want to use system call and passing argument.

Passing an argument to command(3) is easy but you may not want to have problems with threading and child processes.

If you are going to implement these complex operations, you may want to look at how the commands do then, by using tusc on them.

What type of performance do you need for copying a file, 6) and 3)?

I assume by 2) you mean chdir(2) and not rename(3)?
RobertClark
Occasional Contributor

Re: Help Needed in C++

Thanks dennis
Well performace is not an issue,because files r not bulky and nu of files are not much hardly 20 at max.

R u aware of some library in C++. and yeap ur right its chdir not rename

Ralph Grothe
Honored Contributor

Re: Help Needed in C++

Mostly these functions are implemented in procedural C.
I don't know of OO APIs in C++.
Maybe projetcs like KDE or GNOME (or many of the other more lightweigt X windo managers) have implemented a C++ interface to them?
Or if you want to implement such a class yourself you could have a look at the C implementations of the FSF,
e.g.

http://ftp.gnu.org/gnu/fileutils/fileutils-4.1.tar.gz
Madness, thy name is system administration
Sanjay Yugal Kishore Ha
Frequent Advisor

Re: Help Needed in C++

Hello Robert,

We had used similar directory operations with C++ classes in our project. But we resorted to directory(3C) for the actual methods.

As the directory apis are pretty much standard across unix flavors, we figured it would be more easier to recompile for the different flavours than overload the unix implementations with our own methods.

HTH,
Sanjay
Dying is the last thing that I will do.