IPhone DevelopmentHow to obtain surplus in an applicationDisk SpaceThe Code is the content to be introduced in this article, mainly to understandIphone DevelopmentRemaining ApplicationDisk Space. There is not much content, mainly through code. This code shows how to obtain the remaining disk space of the iPhone and all the disk space.
- #include <sys/param.h>
- #include <sys/mount.h>
- long long freeSpace() {
- struct statfs buf;
- long long freespace = -1;
- if(statfs("/", &buf) >= 0){
- freespace = (long long)buf.f_bsize * buf.f_bfree;
- }
-
- return freespace;
- }
-
- +(float)getTotalDiskSpaceInBytes {
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- struct statfs tStats;
- statfs([[paths lastObject] cString], &tStats);
- float totalSpace = (float)(tStats.f_blocks * tStats.f_bsize);
- return totalSpace;
- }
Summary:IPhone DevelopmentHow to obtain surplus in an applicationDisk SpaceThe content of the Code has been introduced. I hope this article will help you!