コード例 #1
0
ファイル: Path.cpp プロジェクト: asmCode/PixItAllTizen
void Path::GetAllFiles(std::vector<std::string> &files,
					   const std::string &path,
					   const std::string &filter)
{
	Directory* pDir = new Directory();
	DirEnumerator* pDirEnum;

	result r = pDir->Construct(path.c_str());
	if (r != E_SUCCESS)
	{
		AppLog(GetErrorMessage(r));
		delete pDir;
		return;
	}

    pDirEnum = pDir->ReadN();

	while (pDirEnum->MoveNext() == E_SUCCESS)
	{
		DirEntry entry = pDirEnum->GetCurrentDirEntry();

		if (entry.IsDirectory())
			continue;

		Path fileName(StringUtils::ToNarrow(entry.GetName().GetPointer()));

		if (fileName.GetExt() == filter.substr(filter.size() - 3))
		{
			files.push_back(fileName.GetFilenameExt());
		}
	}

	delete pDir;
	delete pDirEnum;
}
コード例 #2
0
void ZLbadaPaintContext::collectFiles(std::map<std::string, std::string> &names, const char* path ) {
   //TODO collectFiles
	 AppLog("ZLbadaPaintContext::collectFiles") ;
    Directory dir;
    DirEnumerator *pDirEnum = null;
    result r = E_SUCCESS;

    // Opens the directory
    r = dir.Construct(path);
	 AppLog(" dir.Construct %s",path) ;
    if(IsFailed(r))  AppLog("IsFailed");

       //goto CATCH;

    // Reads all the directory entries
    pDirEnum = dir.ReadN();
  //  if(!pDirEnum)
  //      goto CATCH;
    while(pDirEnum->MoveNext() == E_SUCCESS)
    {
        DirEntry dirEntry = pDirEnum->GetCurrentDirEntry();
        Tizen::Base::String str = dirEntry.GetName();
       // AppLog("dirEntry name Length = %d",str.GetLength()) ;
        Utf8Encoding utf8;
       	ByteBuffer* pBB = utf8.GetBytesN(str);
        std::string  shortName((const char*)pBB->GetPointer());//,str.GetLength());
        AppLog("dirEntry name = %s",shortName.c_str()) ;
        if (shortName !="." && shortName !="..")	{
        	std::string fullName;
        	fullName = path + shortName;
        	AppLog("fullName = %s",fullName.c_str());
        	names.insert(std::make_pair(shortName,fullName));
        }
        delete pBB;
       // names.push_back(shortName);
    }

    // Deletes the enumerator
    delete pDirEnum;

    AppLog("Succeeded");
}
コード例 #3
0
XMDir* xmBadaOpendir ( const KDchar* dirname )
{
	Directory   dir;
	XMDir*      ret;
	result      r;

	r = dir.Construct ( dirname );

	if ( IsFailed ( r ) )
	{
		ret = 0;
		goto failed;
	}

	ret = (XMDir *) kdMalloc ( sizeof ( XMDir ) );
	if ( ret )
	{
		ret->dir_enum = dir.ReadN ( );
		ret->dir_info.d_name = (const KDchar *) kdMalloc ( 256 );
	}
	else
	{
		goto failed;
	}

	return ret;

failed :

	if ( ret )
	{
		kdFree( ret );
		ret = 0;
	}

	xmBadaSetError ( r );

	return ret;
}
コード例 #4
0
ファイル: CategoryItemForm.cpp プロジェクト: Vizantiec/Bada
result
CategoryItemForm::ReadCustomListItems()
{
	result r = E_SUCCESS;
	String dirName(L"/Home/catalog/"+dir);
	Directory* pDir;
	DirEnumerator* pDirEnum;

	pDir = new Directory; // allocate Directory instance

	// Open directory
	r = pDir->Construct(dirName);

	// Read all directory entries
	pDirEnum = pDir->ReadN();

	String contentType;
	int i = 0;
	while(pDirEnum->MoveNext() == E_SUCCESS) {
		DirEntry dirEntry = pDirEnum->GetCurrentDirEntry();
		if(dirEntry.IsNomalFile()) {
			//AppLog("%S", dirEntry.GetName().GetPointer());
			if(!dirEntry.GetName().Equals("category.info", false)) {

				String fileName(dirName+"/"+dirEntry.GetName());

				String title, desc;
				String iTempStr, iTempStr2;

				File file;
				result r = file.Construct(fileName, L"r");
				if( IsFailed(r) )
				{
						AppLog("File::Consturct() is failed by %s", GetErrorMessage(r));
				}

				FileAttributes fileAttrs;
				file.GetAttributes(fileName, fileAttrs);
				long long size = fileAttrs.GetFileSize();


				ByteBuffer readBuffer;
				readBuffer.Construct((int)size + 1);

				r = file.Read(readBuffer);
				if( IsFailed(r) )
				{
						AppLog("File::Read() is failed by %s", GetErrorMessage(r));
				}

				char* data = new char[readBuffer.GetLimit()+1];
				readBuffer.SetPosition(0);
				readBuffer.GetArray((byte*)data, 0, readBuffer.GetLimit());
				data[readBuffer.GetLimit()] ='\0';
				//String str = String(data);

				String str;
				r = StringUtil::Utf8ToString(data, str);
				delete data;
				if(IsFailed(r)) {
					AppLog("File read error. File : %S", fileName.GetPointer());
					continue;
				}

				file.Seek(FILESEEKPOSITION_BEGIN, 0);
				file.Read(title);

				r = TextPic::GetTranslated(title);
				if (IsFailed(r)) {
					continue;
				}

				int linecount = 0;
				while(file.Read(iTempStr) != E_END_OF_FILE) {
					linecount++;
					iTempStr2.Append(iTempStr);
				}

				anciilist.Add(*(new String(iTempStr2)));
				titlelist.Add(*(new String(title)));
				filelist.Add(*(new String(fileName)));

				ItemListForm::AddListItem(*CategoryList, title, iTempStr2, i++, linecount);
				file.Flush();
			}
		}
	}

	delete pDirEnum;
	delete pDir;

	return r;
}
コード例 #5
0
ファイル: fs.cpp プロジェクト: alexnikleo/scummvm
bool BadaFilesystemNode::getChildren(AbstractFSList &myList,
																		 ListMode mode, bool hidden) const {
	AppAssert(isDirectory());

	bool result = false;

	if (_isVirtualDir && mode != Common::FSNode::kListFilesOnly) {
		// present well known BADA file system areas
		if (_path == PATH_ROOT) {
			myList.push_back(new BadaFilesystemNode(PATH_HOME));
			myList.push_back(new BadaFilesystemNode(PATH_HOME_EXT));
			myList.push_back(new BadaFilesystemNode(PATH_MEDIA));
			myList.push_back(new BadaFilesystemNode(PATH_CARD));
			result = true; // no more entries
		} else if (_path == PATH_CARD) {
			myList.push_back(new BadaFilesystemNode(PATH_CARD_MEDIA));
			result = true; // no more entries
		} else if (_path == PATH_HOME) {
			// ensure share path is always included
			myList.push_back(new BadaFilesystemNode(PATH_HOME_SHARE));
			myList.push_back(new BadaFilesystemNode(PATH_HOME_SHARE2));
		}
	}

	if (!result) {
		DirEnumerator *pDirEnum = 0;
		Directory *pDir = new Directory();

		// open directory
		if (IsFailed(pDir->Construct(_unicodePath))) {
			AppLog("Failed to open directory: %S", _unicodePath.GetPointer());
		} else {
			// read all directory entries
			pDirEnum = pDir->ReadN();
			if (pDirEnum) {
				result = true;
			}

			// loop through all directory entries
			while (pDirEnum && pDirEnum->MoveNext() == E_SUCCESS) {
				DirEntry dirEntry = pDirEnum->GetCurrentDirEntry();

				// skip 'invisible' files if necessary
				Osp::Base::String fileName = dirEntry.GetName();

				if (fileName[0] == '.' && !hidden) {
					continue;
				}

				// skip '.' and '..' to avoid cycles
				if (fileName == L"." || fileName == L"..") {
					continue;
				}

				// Honor the chosen mode
				if ((mode == Common::FSNode::kListFilesOnly && dirEntry.IsDirectory()) ||
						(mode == Common::FSNode::kListDirectoriesOnly && !dirEntry.IsDirectory())) {
					continue;
				}
				myList.push_back(new BadaFilesystemNode(_path, fromString(fileName)));
			}
		}

		// cleanup
		if (pDirEnum) {
			delete pDirEnum;
		}

		// close the opened directory
		if (pDir) {
			delete pDir;
		}
	}

	return result;
}