Skip to content

Instantly share code, notes, and snippets.

@BlueCocoa
Created May 9, 2015 10:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlueCocoa/0f5492b9d85f07ec50a2 to your computer and use it in GitHub Desktop.
Save BlueCocoa/0f5492b9d85f07ec50a2 to your computer and use it in GitHub Desktop.
Get iOS storage size
@import Darwin.sys.mount;
int main(int argc, const char * agrv[]) {
struct statfs buf;
long long freespace = 0;
if(statfs("/", &buf) >= 0){
freespace = (long long)buf.f_bsize * buf.f_blocks;
}
if(statfs("/private/var", &buf) >= 0){
freespace += (long long)buf.f_bsize * buf.f_blocks;
}
printf("%lld\n",freespace);
}
@BlueCocoa
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment