| 143 | |
| 144 | #ifndef SFX_MODULE |
| 145 | int64 GetFreeDisk(const wchar *Name) |
| 146 | { |
| 147 | #ifdef _WIN_ALL |
| 148 | wchar Root[NM]; |
| 149 | GetFilePath(Name,Root,ASIZE(Root)); |
| 150 | |
| 151 | ULARGE_INTEGER uiTotalSize,uiTotalFree,uiUserFree; |
| 152 | uiUserFree.u.LowPart=uiUserFree.u.HighPart=0; |
| 153 | if (GetDiskFreeSpaceEx(*Root!=0 ? Root:NULL,&uiUserFree,&uiTotalSize,&uiTotalFree) && |
| 154 | uiUserFree.u.HighPart<=uiTotalFree.u.HighPart) |
| 155 | return INT32TO64(uiUserFree.u.HighPart,uiUserFree.u.LowPart); |
| 156 | return 0; |
| 157 | #elif defined(_UNIX) |
| 158 | wchar Root[NM]; |
| 159 | GetFilePath(Name,Root,ASIZE(Root)); |
| 160 | char RootA[NM]; |
| 161 | WideToChar(Root,RootA,ASIZE(RootA)); |
| 162 | struct statvfs sfs; |
| 163 | if (statvfs(*RootA!=0 ? RootA:".",&sfs)!=0) |
| 164 | return 0; |
| 165 | int64 FreeSize=sfs.f_bsize; |
| 166 | FreeSize=FreeSize*sfs.f_bavail; |
| 167 | return FreeSize; |
| 168 | #else |
| 169 | return 0; |
| 170 | #endif |
| 171 | } |
| 172 | #endif |
| 173 | |
| 174 |
no test coverage detected