예제 #1
0
static void addAllFiles( HWND hwnd )
{
    HWND        ctl;
    int         cnt;
    int         i;
    char        *buf;
    LRESULT     alloced;
    LRESULT     len;

    alloced = 512;
    buf = new char [alloced];

    ctl = GetDlgItem( hwnd, FOD_FILES );
    cnt = (int)SendMessage( ctl, LB_GETCOUNT, 0, 0 );
    for( i = 0; i < cnt; i++ ) {
        len = SendMessage( ctl, LB_GETTEXTLEN, i, 0 );
        len++;
        if( len > alloced ) {
            delete buf;
            buf = new char [len];
            alloced = len;
        }
        SendMessage( ctl, LB_GETTEXT, i, (LPARAM)(LPSTR)buf );
        addFileToList( hwnd, buf );
    }
    free( buf );
}
예제 #2
0
static void addCurrentFile95( HWND hwnd )
{
    char        fname[MAX_PATH];
    struct stat buf;
    SendMessage( GetParent( hwnd ), CDM_GETSPEC, MAX_PATH, (LPARAM)fname );
    if( fname[strlen( fname ) - 1] == '\\' ) return;
    stat( fname, &buf );
    if( S_ISDIR( buf.st_mode ) ) return;
    if( strpbrk( fname, "?*" ) != NULL ) return;
    addFileToList( hwnd, fname );
}
예제 #3
0
void MainWindow::on_actionAddFile_triggered()
{
    QSettings settings;
    auto files = QFileDialog::getOpenFileNames(this, tr("Select files to add"), settings.value(cSettingsAddFileDirectory, QString()).toString());
    if (files.size() > 0) {
        QFileInfo fileInfo(files.first());
        if (fileInfo.exists()) {
            settings.setValue(cSettingsAddFileDirectory, fileInfo.absolutePath());
        }
    }
    for (auto file : files) {
        addFileToList(file);
    }
    updateButtonStates();
}
예제 #4
0
static void addCurrentFile( HWND hwnd  ) {
    char        *fname;
    int          len;
    HWND         ctl;
    struct stat  buf;

    ctl = GetDlgItem( hwnd, FOD_FILENAME );
    len = GetWindowTextLength( ctl );
    if( len == 0 ) return;
    fname = (char *)alloca( len + 1 );
    GetWindowText( ctl, fname, len + 1 );
    if( fname[strlen( fname ) - 1] == '\\' ) return;
    stat( fname, &buf );
    if( S_ISDIR( buf.st_mode ) ) return;
    if( strpbrk( fname, "?*" ) != NULL ) return;
    addFileToList( hwnd, fname );
    SetWindowText( ctl, "" );
}
예제 #5
0
void FileSystem_impl::buildFileListFromDirectory(const char *dir) {
	WIN32_FIND_DATA findData;
	char searchPath[MAX_PATH];
	snprintf(searchPath, sizeof(searchPath), "%s/*", dir);
	HANDLE h = FindFirstFile(searchPath, &findData);
	if (h) {
		do {
			if (findData.cFileName[0] == '.') {
				continue;
			}
			char filePath[MAX_PATH];
			snprintf(filePath, sizeof(filePath), "%s/%s", dir, findData.cFileName);
			if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
				buildFileListFromDirectory(filePath);
			} else {
				addFileToList(filePath);
			}
		} while (FindNextFile(h, &findData));
		FindClose(h);
	}
}
예제 #6
0
bool Parser::parseRecursive ( const std::string directory, ProgramOptions &options, Map &fileList ) {

    fs::path path ( fs::initial_path() );
    path = fs::system_complete ( fs::path ( directory ) ); //returns reference to the file

    if ( !fs::exists ( path ) ) {
        std::cerr << "Could not find: " << path << std::endl;
        return false;
    }

    for ( fs::recursive_directory_iterator end, dir ( options.getStartDirectory() ); dir != end; ++dir ) {
        try {
            if ( fs::is_regular_file ( dir->path().string() ) )
                addFileToList ( dir->path().string(), options, fileList );
            else
                continue;
        } catch ( std::exception const& ex ) {
            std::cerr << dir->path() << " " << ex.what() << std::endl;
        }
    }
    return true;
}
예제 #7
0
void FileSystem_impl::buildFileListFromDirectory(const char *dir) {
	DIR *d = opendir(dir);
	if (d) {
		dirent *de;
		while ((de = readdir(d)) != NULL) {
			if (de->d_name[0] == '.') {
				continue;
			}
			char filePath[512];
			snprintf(filePath, sizeof(filePath), "%s/%s", dir, de->d_name);
			struct stat st;
			//if (stat(filePath, &st) == 0) {
				if (S_ISDIR(st.st_mode)) {
					buildFileListFromDirectory(filePath);
				} else {
					addFileToList(filePath);
				}
			//}
		}
		closedir(d);
	}
}
예제 #8
0
static void addAllFiles95( HWND hwnd ) {
    int             i;
    int             n;
    GetFilesInfo    *info;
    const char      *ext;
    char            folder[_MAX_PATH];
    char            path[_MAX_PATH];
    WIN32_FIND_DATA wfd;
    HANDLE          find_handle;
    BOOL            found = TRUE;
    char            *fname;

    info = (GetFilesInfo *)GET_DLGDATA( hwnd );
    ext = info->filter;
    n = info->filter_index * 2 - 1;
    for( i = 0; i < n; i++ ) {
        ext = strchr( ext, '\0' );
        ext++;
    }
    SendMessage( GetParent( hwnd ), CDM_GETFOLDERPATH, _MAX_PATH, (LPARAM)folder );
    _makepath( path, NULL, folder, ext, NULL );
    find_handle = FindFirstFile( path, &wfd );
    if( find_handle != NULL ) {
        while( found ) {
            if( !(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ) {
                fname = strrchr( wfd.cFileName, '\\' );
                if( fname != NULL ) {
                    fname++;
                } else {
                    fname = wfd.cFileName;
                }
                addFileToList( hwnd, fname );
            }
            found = FindNextFile( find_handle, &wfd );
        }
        FindClose( find_handle );
    }
}