File handling in C++ on Linux/Unix platform

Hi everyone,

I have a bunch of file handling code that I am writing in VC++ 6.0. I am mostly using the methods defined in <io.h> such as _finddata_t structure , _chdir(), rename(), _getcwd() and alike. At sime point it might be necessary to compile the application I am coding on a Linux platform. I don't think these methods are unix compatible. I don't have any experience coding on a linux/unix platform. I need to know if there are any file handling modules that can be compatible on both platforms or a way to make minimal changes to the existing code which makes it possible to compile it on a linux platform.

Any suggestions or reference to a resource(online, books,...) is appreciated.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

For the I/O itself, try sticking with the C++ library, specifically iostream and related classes.

Unfortunately, these don't address directory issues.  

onlyshizaAuthor Commented:
well,  it's mostly directory manipulation like finding the name of the current directory, file names in a directory or renaming/ deleting/ saving a file.
Most of the directory functions are available in Linux/UNIX.
However, you should remove the leading underscore when you use it in your code.

So use chdir() instead of _chdir().

chdir() will compile in Windows and Linux/UNIX, but _chdir() does not compile on Linux/UNIX.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

onlyshizaAuthor Commented:
thanks Axter. How about the _finddata_t structure. Is this also supported on Linux/UNIX or is there any similar structure?
Unfortunately, the find directory logic is not the same.  Most Linux/UNIX platforms use the type of find directory functions used in the Bordland compiler.

You'll find other directory functions like chdir, mkdir, rmdir, etc..

info libc

Enter this at command prompt in linux for complete documentation of all available functions.

There are sub-topics for file handling and I/O.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.