Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Bypp · Jun 18, 2014 at 08:56 PM · c#macdiskspace

System.IO.DriveInfo returns wrong disk space values on Mac

I am having trouble getting the correct AvailableFreeSpace values from my Mac desktop computer. I am working with Unity3D C#, and am using the following code :

 DriveInfo[] drives =DriveInfo.GetDrives();
 
 foreach(DriveInfo drive in drives)
 {
     if(drive.IsReady)
     {
         Debug.Log(drive.Name);
         Debug.Log(drive.AvailableFreeSpace);
         Debug.Log(drive.TotalFreeSpace);
         Debug.Log(drive.TotalSize);
     }
 }
 

My results are a bit weird. I'm only getting one drive : The name I'm getting is "/", and ythe values are wrong. AvailableFreeSpace returns a higher value than TotalSize, which makes no sense. Also, the DriveType is Unknown and the drive Format is unixfs, if that helps.

Don't know if I'm missing something obvious about the file structure on a Mac computer, maybe?

I have a SATA HDD with 500go divided into two partitions. Shouldn't it give me 2 drives?

EDIT : My Monodevelop version is 4.0.1, so I don't think this is related to the bug reported years ago on version 2.10.0 or something like that.

What am I doing wrong?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fschneider · Mar 04, 2016 at 12:28 PM 0
Share

Still the case in 2016

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Mar 04, 2016 at 01:02 PM

Well, i don't have a mac, but Unix based systems (like MacOS / Linux) don't really work with "drives" in the same sense as Windows does. The filesystem only has a root folder and any HDD partition is usually mapped to a "folder" inside the root folder.

Since NTFS such a behaviour can also be used on Windows machines. Instead of giving an HDD partition a drive letter you can map it into a folder of another drive. I would guess that by doing so you would get similar strange results. "TotalSize" is most likely related to the "main" drive while the other two might be calculated from the actual available space.

On windows for example the "windows" folder uses a lot hardlinks inside subfolders. This makes the size of the windows folder to appear way larger than it actually is since some files / folders are counted multiple times.

As far as i can read from the MSDN documentation, "TotalSize" and "TotalFreeSpace" actually belong to the physical drive while "AvailableFreeSpace" might take mapped drives into account as well.

I can't test any of those since i don't have a Mac.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Error with nested coroutines 0 Answers

Google Cardboard problem with Unity 5.6 for iOS when compiling the project on Xcode 2 Answers

In-app purchase "Invalid product" on Mac Store build 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges