Evo510
Evo510

Reputation: 173

How would I go about checking the file system I'm working on in C

I'm making a program and one of the things it needs to do is transfer files. I would like to be able to check before I start moving files if the File system supports files of size X. What is the best way of going about this?

Upvotes: 1

Views: 94

Answers (2)

Blagovest Buyukliev
Blagovest Buyukliev

Reputation: 43558

Go on with using a function like ftruncate to create a file of the desired size in advance, before the moving, and do the appropriate error-handling in case it fails.

Upvotes: 2

Vicky
Vicky

Reputation: 13244

There's no C standard generic API for this. You could simply try creating a file and writing junk to it until it is the size you want, then deleting it, but even that isn't guaranteed to give you the info you need - for instance another process might have come and written a large file in between your test and your transfer, taking up space you were hoping to use.

Upvotes: 2

Related Questions