struct dirent *win_readdir(UNFS3_WIN_DIR * dir)
{
    if (dir->stream == NULL) {
	/* Emulate root */
	for (; dir->currentdrive < MAX_NUM_DRIVES; dir->currentdrive++) {
	    if (dir->logdrives & 1 << dir->currentdrive)
		break;
	}

	if (dir->currentdrive < MAX_NUM_DRIVES) {
	    dir->de.d_name[0] = 'a' + dir->currentdrive;
	    dir->de.d_name[1] = '\0';
	    dir->currentdrive++;
	    return &dir->de;
	} else {
	    return NULL;
	}
    } else {
	struct _wdirent *de;

	de = _wreaddir(dir->stream);
	if (!de) {
	    return NULL;
	}

	if (!WideCharToMultiByte
	    (CP_UTF8, 0, de->d_name, -1, dir->de.d_name,
	     sizeof(dir->de.d_name), NULL, NULL)) {
	    logmsg(LOG_CRIT, "win_readdir: WideCharToMultiByte failed");
	    return NULL;
	}
	return &dir->de;
    }
}
示例#2
0
static int number_of_file(char *path)
{
	int count = 0;
#ifdef WIN32
	struct _wdirent *entry;
	_WDIR *dirp = (_WDIR *)subsurface_opendir(path);
#else
	struct dirent *entry;
	DIR *dirp = (DIR *)subsurface_opendir(path);
#endif

	while (dirp) {
#ifdef WIN32
		entry = _wreaddir(dirp);
		if (!entry)
			break;
#else
		entry = readdir(dirp);
		if (!entry)
			break;
		if (entry->d_type == DT_REG) /* If the entry is a regular file */
#endif
		count++;
	}
#ifdef WIN32
	_wclosedir(dirp);
#else
	closedir(dirp);
#endif
	return count;
}
示例#3
0
/**
 * g_dir_read_name:
 * @dir: a #GDir* created by g_dir_open()
 *
 * Retrieves the name of the next entry in the directory.  The '.' and
 * '..' entries are omitted. On Windows, the returned name is in
 * UTF-8. On Unix, it is in the on-disk encoding.
 *
 * Return value: The entry's name or %NULL if there are no 
 *   more entries. The return value is owned by GLib and
 *   must not be modified or freed.
 **/
G_CONST_RETURN gchar*
g_dir_read_name (GDir *dir)
{
#ifdef G_OS_WIN32
  gchar *utf8_name;
  struct _wdirent *wentry;
#else
  struct dirent *entry;
#endif

  g_return_val_if_fail (dir != NULL, NULL);

#ifdef G_OS_WIN32
  while (1)
    {
      wentry = _wreaddir (dir->wdirp);
      while (wentry 
	     && (0 == wcscmp (wentry->d_name, L".") ||
		 0 == wcscmp (wentry->d_name, L"..")))
	wentry = _wreaddir (dir->wdirp);

      if (wentry == NULL)
	return NULL;

      utf8_name = g_utf16_to_utf8 (wentry->d_name, -1, NULL, NULL, NULL);

      if (utf8_name == NULL)
	continue;		/* Huh, impossible? Skip it anyway */

      strcpy (dir->utf8_buf, utf8_name);
      g_free (utf8_name);

      return dir->utf8_buf;
    }
#else
  entry = readdir (dir->dirp);
  while (entry 
         && (0 == strcmp (entry->d_name, ".") ||
             0 == strcmp (entry->d_name, "..")))
    entry = readdir (dir->dirp);

  if (entry)
    return entry->d_name;
  else
    return NULL;
#endif
}
示例#4
0
BBString *readdir_( int dir ){
	if( _bbusew ){
		struct _wdirent *t=_wreaddir( (_WDIR*)dir );
		return t ? bbStringFromWString( t->d_name ) : &bbEmptyString;
	}
	struct dirent *t=readdir( (DIR*)dir );
	return t ? bbStringFromCString( t->d_name ) : &bbEmptyString;
}
示例#5
0
void GetDirContents(const std::wstring& path, 
					std::list<std::wstring>& contents)
	{
	_WDIR* currDir =  _wopendir(path.c_str());
	if(currDir == NULL)
		{
		return;
		}
	
	_wdirent* currElem = _wreaddir(currDir);
	
	while (currElem)
		{
		contents.push_back(currElem->d_name);
		currElem = _wreaddir(currDir);
		}
	_wclosedir(currDir);
	}
示例#6
0
int main(int argc, char **argv)
{
    struct _wdirent *di;
    _WDIR *h = _wopendir (L".");
    if (!h)
        return 1;
    while ((di = _wreaddir (h)) != NULL)
        printf ("%ws\n", di->d_name);
    _wclosedir (h);
    return 0;
}
示例#7
0
文件: savedialog.cpp 项目: Try/game
std::vector<std::wstring> SaveDialog::filesInDir( const std::wstring &dirName ){
  std::vector<std::wstring> vec;
  (void)dirName;

#ifndef __ANDROID__
  _WDIR *dir = _wopendir ( dirName.c_str() );//data->curDir;
  struct _wdirent *ent;
  
  //dir = _wopendir ( dirName.c_str() );
  if (dir != NULL) {
    /* print all the files and directories within directory */
    while ((ent = _wreaddir (dir)) != NULL) {
      vec.push_back( ent->d_name );
      }
    _wclosedir (dir);
    } else {
    //return EXIT_FAILURE;
    }
#endif

  return vec;
  }
示例#8
0
struct _wdirent *
lisp_readdir(_WDIR *dir)
{
  return _wreaddir(dir);
}