Пример #1
0
/**
 * @brief Creates a directory tree.
 * @param[in] path the native path.
 * @return Zero for success,
 * negative value otherwise.
 */
int winx_create_path(wchar_t *path)
{
    /*wchar_t rootdir[] = L"\\??\\X:\\";*/
    winx_volume_information v;
    wchar_t *p;
    size_t n;
    
    if(path == NULL)
        return (-1);

    /* path must contain at least \??\X: */
    if(wcsstr(path,L"\\??\\") != path || wcschr(path,':') != (path + 5)){
        etrace("native path must be specified");
        return (-1);
    }

    n = wcslen(L"\\??\\X:\\");
    if(wcslen(path) <= n){
        /* check for volume existence */
        /*
        rootdir[4] = path[4];
        // may fail with access denied status
        return winx_create_directory(rootdir);
        */
        return winx_get_volume_information((char)path[4],&v);
    }
    
    /* skip \??\X:\ */
    p = path + n;
    
    /* create directory tree */
    while((p = wcschr(p,'\\'))){
        *p = 0;
        if(winx_create_directory(path) < 0){
            *p = '\\';
            etrace("cannot create %ws",path);
            return (-1);
        }
        *p = '\\';
        p ++;
    }
    
    /* create target directory */
    if(winx_create_directory(path) < 0){
        etrace("cannot create %ws",path);
        return (-1);
    }
    
    return 0;
}
Пример #2
0
static wchar_t *get_report_path(udefrag_job_parameters *jp)
{
    wchar_t *instdir, *fpath;
    wchar_t *isportable;//genBTC
    wchar_t *path = NULL;

    isportable = winx_getenv(L"UD_IS_PORTABLE");//genBTC
    if(isportable != NULL){
        /* portable version? */
        fpath = winx_get_module_filename();
        if(fpath == NULL){
            etrace("cannot get program\'s path");
        } else {
            winx_path_remove_filename(fpath);
            path = winx_swprintf(L"\\??\\%ws\\reports",fpath);
            if(path == NULL){
                etrace("not enough memory (case 1)");
            } else {
                (void)winx_create_directory(path);
                winx_free(path);
            }
            path = winx_swprintf(L"\\??\\%ws\\reports\\fraglist_%c.luar",
                fpath,winx_tolower(jp->volume_letter));
            if(path == NULL)
                etrace("not enough memory (case 2)");
            winx_free(fpath);
        }
    } else {
        instdir = winx_getenv(L"UD_INSTALL_DIR");
        /* regular installation */
        path = winx_swprintf(L"\\??\\%ws\\reports",instdir);
        if(path == NULL){
            etrace("not enough memory (case 3)");
        } else {
            (void)winx_create_directory(path);
            winx_free(path);
        }
        path = winx_swprintf(L"\\??\\%ws\\reports\\fraglist_%c.luar",
            instdir,winx_tolower(jp->volume_letter));
        if(path == NULL)
            etrace("not enough memory (case 4)");
        winx_free(instdir);
    }
    return path;
}