~ubuntu-branches/ubuntu/vivid/freerdp/vivid

« back to all changes in this revision

Viewing changes to channels/drive/client/statvfs.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-11-11 12:20:50 UTC
  • mfrom: (1.2.5)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20141111122050-7z628f4ab38qxad5
Tags: upstream-1.1.0~git20140921.1.440916e+dfsg1
ImportĀ upstreamĀ versionĀ 1.1.0~git20140921.1.440916e+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * FreeRDP: A Remote Desktop Protocol Implementation
 
3
 * statvfs emulation for Windows
 
4
 *
 
5
 * Copyright 2012 Gerald Richter
 
6
 *
 
7
 * Licensed under the Apache License, Version 2.0 (the "License");
 
8
 * you may not use this file except in compliance with the License.
 
9
 * You may obtain a copy of the License at
 
10
 *
 
11
 *     http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
13
 * Unless required by applicable law or agreed to in writing, software
 
14
 * distributed under the License is distributed on an "AS IS" BASIS,
 
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
16
 * See the License for the specific language governing permissions and
 
17
 * limitations under the License.
 
18
 */
 
19
 
 
20
#include <string.h>
 
21
#include <malloc.h>
 
22
 
 
23
#include <winpr/crt.h>
 
24
#include <winpr/windows.h>
 
25
 
 
26
#include "statvfs.h"
 
27
 
 
28
int statvfs(const char *path, struct statvfs *buf)
 
29
{
 
30
        BOOL res;
 
31
        int len;
 
32
        LPWSTR unicodestr;
 
33
        DWORD lpSectorsPerCluster;
 
34
        DWORD lpBytesPerSector;
 
35
        DWORD lpNumberOfFreeClusters;
 
36
        DWORD lpTotalNumberOfClusters;
 
37
 
 
38
        len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
 
39
        unicodestr = (LPWSTR) malloc(len);
 
40
        MultiByteToWideChar(CP_ACP, 0, path, -1, unicodestr, len);
 
41
 
 
42
        res = GetDiskFreeSpace(unicodestr, &lpSectorsPerCluster, &lpBytesPerSector, &lpNumberOfFreeClusters, &lpTotalNumberOfClusters);
 
43
 
 
44
        buf->f_bsize = lpBytesPerSector; /* file system block size */
 
45
        buf->f_frsize = 0; /* fragment size */
 
46
        buf->f_blocks = lpTotalNumberOfClusters; /* size of fs in f_frsize units */
 
47
        buf->f_bfree = lpNumberOfFreeClusters; /* # free blocks */
 
48
        buf->f_bavail = lpNumberOfFreeClusters; /* # free blocks for unprivileged users */
 
49
        buf->f_files = 0; /* # inodes */
 
50
        buf->f_ffree = 0; /* # free inodes */
 
51
        buf->f_favail = 0; /* # free inodes for unprivileged users */
 
52
        buf->f_fsid = lpNumberOfFreeClusters & 0xffff; /* file system ID */
 
53
        buf->f_flag = 0; /* mount flags */
 
54
        buf->f_namemax = 250; /* maximum filename length */
 
55
        
 
56
        return res;
 
57
}