Skip to main content

Featured

Build docker image from multiple build contexts

Build docker image from multiple build contexts Building a docker image requires specifying a source of truth to include in the image from a local directory or a remote git repository. In the previous version, the docker BuildKit allows users to specify the build context from a single source of truth only. However, the engineers may need to have the context from different locations based on the type of files. For instance, icons, images or other resources that are not included in the same package, including the resource from other docker images. Fortunately, the Docker Buildx toolkit supports multiple build context flag for Docker 1.4. Let's learn how to use this new feature. The following list is a shortcut for jumping into a specific topic handy. What version of Docker is this tutorial targeting? How to specify the version of Dockerfile frontend? Ho

[WINAPI]取得磁碟空間

可使用GetDiskFreeSpaceEx()來取得目前可使用的磁碟空間、總磁碟空間以及總剩餘磁碟空間。

使用方式如下:


    char szDiskDir[MAX_PATH]  = "C:\\";

    //A pointer to a variable that receives the total number of free bytes on a disk that are available to the user who is associated with the calling thread.
    //This parameter can be NULL.
    //If per-user quotas are being used, this value may be less than the total number of free bytes on a disk.
    __int64 n64AvailableFreeDiskBytes;       

    //A pointer to a variable that receives the total number of bytes on a disk that are available to the user who is associated with the calling thread.
    //This parameter can be NULL.
    //If per-user quotas are being used, this value may be less than the total number of bytes on a disk.
    //To determine the total number of bytes on a disk or volume, use IOCTL_DISK_GET_LENGTH_INFO.        
    __int64 n64TotalDiskBytes;

    //A pointer to a variable that receives the total number of free bytes on a disk.
    //This parameter can be NULL.
    __int64 n64TotalFreeDiskBytes;

    if ( !::GetDiskFreeSpaceEx(szDiskDir, (PULARGE_INTEGER) &n64AvailableFreeDiskBytes, (PULARGE_INTEGER) &n64TotalDiskBytes,
                                                            (PULARGE_INTEGER) &n64TotalFreeDiskBytes) )
    {
        printf("Fail to get disk fress space in %s (Err = %d).\n", szDiskDir, ::GetLastError());
    }else{
        printf("%s has %lld bytes available free disk.\nTotal disk size is %lld bytes.\nTotal free space is %lld bytes.\n", 
                    szDiskDir, n64AvailableFreeDiskBytes, n64TotalDiskBytes, n64TotalFreeDiskBytes);
    }

Comments

Popular Posts