当前位置: 首页>>代码示例>>C++>>正文


C++ Directory::NextEntry方法代码示例

本文整理汇总了C++中Directory::NextEntry方法的典型用法代码示例。如果您正苦于以下问题:C++ Directory::NextEntry方法的具体用法?C++ Directory::NextEntry怎么用?C++ Directory::NextEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Directory的用法示例。


在下文中一共展示了Directory::NextEntry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ls_main

 int ls_main( int argc, char **argv )
 {
    char *node = NULL;
    if ( argc == 1 ) node = strdup("/");
    if ( argc == 2 ) node = strdup( argv[1] );
    if ( node == NULL ) return -1;

    Directory *dir = new Directory( node );
    if ( dir->Exists() == false ) 
    {
      printf("%s\n","directory does not exist.");
    }
  
	char *front = (char*)malloc( strlen(node) + 2 );
		  strcpy( front, node );
		  if ( front[strlen(front) - 1] != '/' ) 
				strcat( front, "/" );

	
     char *entry = NULL;
     while ((entry = dir->NextEntry()) != NULL )
     {
	   char *complete = (char*)malloc(strlen(front) + strlen(entry) + 5 );

		   strcpy( complete, front );
		   strcat( complete, entry );
		   
		   int size = -1;
		   File *temp = new File( complete );
		   if ( temp->Open() >= 0 )
		   {
		     size = temp->Size();
			 temp->Close();
		   }
		   delete temp;
			 
       printf("%5s%10i  %s\n", ". ", size, entry );

	   free( complete );
     }
 
	 free( front );

    printf("%i%s\n", dir->CountEntries(), " files.");
    delete dir;
    free( node );
   
   return 0;
 }
开发者ID:AdamRLukaitis,项目名称:spoon,代码行数:49,代码来源:ls.cpp

示例2: Refresh

bool CommanderWindow::Refresh()
{
	cleanPath();
	list->Empty();
		
	const char *path = input->Text();

	Directory *dir = new Directory( path );
    if ( dir->Exists() == false )  
    {
	  delete dir;
	  Draw( Bounds() );
	  return false;
    }
  
     char *entry = NULL;
     while ((entry = dir->NextEntry()) != NULL )
     {

	   char *complete = (char*)malloc( strlen(path) + strlen(entry) + 2 );

		   strcpy( complete, path );
		   strcat( complete, entry );
		   
		   int size = -1;
		   File *temp = new File( complete );
		   if ( temp->Open() >= 0 )
		   {
		     size = temp->Size();
			 temp->Close();
		   }
		   delete temp;
			 

	   list->AddItem( new StringItem( entry ) );
	   free( complete );
     }

	Draw( Bounds() );
    delete dir;

	return true;
}
开发者ID:AdamRLukaitis,项目名称:spoon,代码行数:43,代码来源:CommanderWindow.cpp


注:本文中的Directory::NextEntry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。