michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsVolumeStat.h" michael@0: #include "nsString.h" michael@0: michael@0: namespace mozilla { michael@0: namespace system { michael@0: michael@0: NS_IMPL_ISUPPORTS(nsVolumeStat, nsIVolumeStat) michael@0: michael@0: nsVolumeStat::nsVolumeStat(const nsAString& aPath) michael@0: { michael@0: if (statfs(NS_ConvertUTF16toUTF8(aPath).get(), &mStat) != 0) { michael@0: memset(&mStat, 0, sizeof(mStat)); michael@0: } michael@0: } michael@0: michael@0: nsVolumeStat::~nsVolumeStat() michael@0: { michael@0: } michael@0: michael@0: /* readonly attribute long long totalBytes; */ michael@0: NS_IMETHODIMP nsVolumeStat::GetTotalBytes(int64_t* aTotalBytes) michael@0: { michael@0: *aTotalBytes = mStat.f_blocks * mStat.f_bsize; michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* readonly attribute long long freeBytes; */ michael@0: NS_IMETHODIMP nsVolumeStat::GetFreeBytes(int64_t* aFreeBytes) michael@0: { michael@0: *aFreeBytes = mStat.f_bfree * mStat.f_bsize; michael@0: return NS_OK; michael@0: } michael@0: michael@0: } // system michael@0: } // mozilla