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


C++ Library::Init方法代码示例

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


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

示例1: CheckForSubIndexes


//.........这里部分代码省略.........
				INT32 ButtonPressed = InformMessage(0, _R(IDS_CREATE), _R(IDS_CANCEL));
				Error::ClearError();

				if(ButtonPressed < 2)
				{
					// Generate an index...
					String_64 Author(PRODUCT_NAME);
					Generate = GenerateDefaultIndex(&SubPath, Path, &Author, Type, TRUE);
					ok = TRUE;
				}
				else
				{
					// Cancel or help clicked
					ok = FALSE;
				}
			}
		}

		if(!Found && !CanGenerate)
		{
			// tell the user that there is no index file, and give them a cancel...
			String_256 WarnMsg;
			String_256 TmpPath(SubPath.GetLocation(FALSE));
			LibraryFile::TidyUpSubPath(&TmpPath);
			WarnMsg.MakeMsg(_R(IDS_LIBRARY_NO_INDEX_FILE), (TCHAR *)IndexDesc, (TCHAR *)TmpPath);
			Error::SetError(0, WarnMsg, 0);
			INT32 ButtonPressed = InformWarning(0, _R(IDS_CANCEL), NULL);
			Error::ClearError();
			ok = FALSE;
		}

		// Check again...
	   	Found = SGLibOil::FileExists(&SubPath);

		if((Found && ok) || (!Found && Generate && ok))
		{
			String_256 Description256 = Path->GetPath();
			AbbreviateName(Description256, 60, TRUE);

			String_64 Description(Description256);
			BOOL DoAgain = TRUE;
			while (DoAgain)
			{
				DoAgain = FALSE;

				// Create the sub lib
				Library *NewSubLib = new Library;

				if (NewSubLib != NULL)
				{
					String_64 DefIndex64(DefaultIndex);
	 				String_256 PathToAdd256 = SubPath.GetLocation(FALSE);
	 				TidyUpSubPath(&PathToAdd256);
					PathName PathToAdd(PathToAdd256);
	 				Error::ClearError();

					// Create the actual group itself
	 				if(NewSubLib->Init(ParentGal, &PathToAdd, &Description, &DefIndex64, Type, Updated))
					{
						Libraries.AddTail(NewSubLib);

						ok = TRUE;

						// Keep track of libraries added for redraw purposes...
						AddNewFolderToScrollRedrawSystem(NewSubLib);
					}
					else
					{
						delete NewSubLib;
						NewSubLib = NULL;

						String_256 WarnMsg;
						String_256 SmallPath;					
						PathToAdd256.Left(&SmallPath, 150);
						
						// "The index for '%s' seems to be invalid and requires updating."						
						WarnMsg.MakeMsg(_R(IDS_LIBRARY_DODGY_INDEX), (TCHAR *)SmallPath);
						Error::SetError(0, WarnMsg, 0);
						INT32 Button = InformWarning(0, _R(IDS_GENERATE), _R(IDS_CANCEL));
						Error::ClearError();

		 				String_256 IPathToAdd256(PathToAdd256);
						SGLibOil::AppendSlashIfNotPresent(&IPathToAdd256);
		 				IPathToAdd256 += TEXT("indexfle.txt");	// This is just to check we can write ok...
						PathName IPathToAdd(IPathToAdd256);

						if(Button == 1)
							DoAgain = SGLibOil::GenerateClicked(ParentLibraryGallery, &IPathToAdd);
					
						if(!DoAgain)
							ok = FALSE;

						Error::ClearError();
					}
				}
			}
		}
	}
	return ok;
}
开发者ID:vata,项目名称:xarino,代码行数:101,代码来源:sgscanf.cpp

示例2: AddSpecificIndex

BOOL LibraryFile::AddSpecificIndex(SuperGallery *ParentGal, PathName *Path, SGLibType Type,
	StringBase *Description, UINT32 bModified, BOOL bIsWebLib)
{
	if(ParentGal == NULL || Path == NULL || !Libraries.IsEmpty() || !Path->IsValid())
	{
		ERROR3("LibraryFile::AddSpecificIndex - Problems on entry");
		return FALSE;
	}

	// Check the path for the library exists
//	if(!SGLibOil::FileExists(Path))
//		return FALSE;

	// Remember the pathname and type
	MyPath = *Path;
	MyType = Type;
	ParentGallery = ParentGal;

	// Create the sub lib
	Library *NewSubLib = new Library;

	if (NewSubLib != NULL)
	{
		// Path = "C:\testlib\animals\xarainfo\animals.txt"
		// Path of files themselves... FilesPath = "C:\testlib\animals"
		NewSubLib->m_bIsWebLib = bIsWebLib;
		PathName TmpPath(Path->GetLocation(FALSE));
		NewSubLib->SetModified(bModified);

		// If it's a root directory we need the slash...
		PathName FilesPath;
		String_256 TmpRootCheck(TmpPath.GetLocation(TRUE));
		if(SGLibOil::IsRootDirectory(&TmpRootCheck))
			FilesPath.SetPathName(TmpPath.GetLocation(TRUE));
		else
			FilesPath.SetPathName(TmpPath.GetLocation(FALSE));

		// Default title for the new group
		String_256 Desc256;
		String_64 Desc64;
		if(Description == NULL)
			Desc256 = Path->GetTruncatedPath(60);
		else
			Desc256 = *Description;
		Desc256.Left(&Desc64, 64);
											
		// The filename of the index
		String_64 IndexFilename(Path->GetFileName(TRUE));

		// Add this new index to the library file and scan it in...
		if(NewSubLib->Init(ParentGal, &FilesPath, &Desc64, &IndexFilename, Type, FALSE, (Description != NULL)))
		{
			Libraries.AddTail(NewSubLib);

			// Keep track of libraries added for redraw purposes...
			AddNewFolderToScrollRedrawSystem(NewSubLib);

			return TRUE;
		}
		else
		{
			// if there was a problem, don't go round leaving memory everywhere...
			delete NewSubLib;
			NewSubLib = NULL;
		}
	}

	// Nothing added
	return FALSE;
}
开发者ID:vata,项目名称:xarino,代码行数:70,代码来源:sgscanf.cpp

示例3: ERROR3

INT32 LibraryFile::Init(SuperGallery *ParentGal, PathName *APath, SGLibType Type, BOOL Updated, BOOL DoScroll)
{
#ifndef EXCLUDE_GALS
	if(ParentGal == NULL || APath == NULL || !Libraries.IsEmpty())
	{
		ERROR3("LibraryFile::Init - NULL parameters are illegal OR Init called > 1 times");
		if(!Libraries.IsEmpty())
			return(Libraries.GetCount());
		else
			return 0;
	}

	BOOL ok = TRUE;

	// Tidy up Path a bit
	String_256 OurPath(APath->GetPath());
	LibraryFile::TidyUpSubPath(&OurPath);

	// Now point Path to the new pathname
	PathName ModifiedPath(OurPath);
	PathName *Path = &ModifiedPath;

	if(!ModifiedPath.IsValid())
	{
		ERROR3("LibraryFile::Init -> Modified library path is invalid");
		return 0;
	}

	// Remember the pathname and type
	MyPath = *Path;
	MyType = Type;

	ParentGallery = ParentGal;
	if(ParentGallery->IsKindOf(CC_RUNTIME_CLASS(LibraryGallery)))
		ParentLibraryGallery = (LibraryGallery *)ParentGal;
	else
	{
		ERROR3("LibraryFile::Init passed a non-library gallery - yikes...");
		return 0;
	}

	// Need to reset the Quiet status before a stream of Library::Init calls
	ParentLibraryGallery->SetQuietStatus(FALSE);

	BOOL Retry = TRUE;
	while(Retry)
	{
		Retry = FALSE;
	
		// Would be nice to have a way of adding a file to a path in PathName... Is there one ?
		if(!SGLibOil::FileExists(Path))
		{
			// We're opening the font gallery, but can't find the font library path - don't warn
			if(Type == SGLib_Font)
				return 0;

			// tell the user that the directory doesn't exist
			String_256 WarnMsg;
			String_256 DefaultIndex;
			String_256 IndexDesc;
			BOOL CanGenerate;
		
			ok = LibraryFile::GetSubIndexDetails(ParentLibraryGallery, &DefaultIndex, &IndexDesc, &CanGenerate);

			String_256 TmpPath(Path->GetLocation(FALSE));
			LibraryFile::TidyUpSubPath(&TmpPath);

			// Taken out by Graham 30/10/97: If the gallery had no directory specified,
			//we used to throw a warning which said "do you want to specify another folder?"
			//We don't do this any more, because the default is to open all galleries empty and
			//then download stuff from the Xara web site
#if 0 
			WarnMsg.MakeMsg(_R(IDS_BROWSE_OR_SCAN), (TCHAR *)IndexDesc, (TCHAR *)TmpPath);
			Error::SetError(0, WarnMsg, 0);
			INT32 ButtonPressed = InformWarning(0, _R(IDS_BROWSE), _R(IDS_RETRY), _R(IDS_CANCEL)/*, _R(IDS_HELP)*/);
#else	// WEBSTER
			INT32 ButtonPressed = 3;
#endif  // WEBSTER
			TRACEUSER( "Richard", _T("ButtonPressed: %d\n"), ButtonPressed);
			Error::ClearError();
			switch(ButtonPressed)
			{
				case 1:
				{
					// Open the Browse dialog (or the Add.. dialog as it seems to be called now)
					PathName ThePath(*Path);
				
					// This returns FALSE if Cancel was hit, or an error occurred.
 					if(!SGLibOil::GetLibPath(ParentLibraryGallery, &ThePath, CanGenerate, Type))
					{
						ERROR3("GetLibPath returned FALSE in LF::Init");
						return 0;
					}
					else
					{
						ModifiedPath = ThePath;
						if(!ModifiedPath.IsValid())
						{
							ERROR3("LibraryFile::Init -> scanned library path is invalid");
							return 0;
//.........这里部分代码省略.........
开发者ID:vata,项目名称:xarino,代码行数:101,代码来源:sgscanf.cpp


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