Esempio n. 1
0
void
EnsureTemplates(void)
{
	// Because creating a new project depends on the existence of the Templates folder,
	// make sure that we have some (very) basic templates to work with if the folder
	// has been deleted.
	DPath templatePath = gAppPath.GetFolder();
	templatePath << "Templates";
	
	bool missing = false;
	BDirectory tempDir;
	if (!BEntry(templatePath.GetFullPath()).Exists())
	{
		BDirectory appDir(gAppPath.GetFolder());
		appDir.CreateDirectory("Templates", &tempDir);
		missing = true;
	}
	else
	{
		tempDir.SetTo(templatePath.GetFullPath());
		if (tempDir.CountEntries() == 0)
			missing = true;
	}
	
	if (missing)
	{
		BDirectory dir;
		tempDir.CreateDirectory("Empty Application", &dir);
		tempDir.CreateDirectory("Kernel Driver", &dir);
		tempDir.CreateDirectory("Shared Library or Addon", &dir);
		tempDir.CreateDirectory("Static Library", &dir);
		
		DPath filePath;
		TextFile file;
		
		filePath = templatePath;
		filePath << "Empty Application/TEMPLATEINFO";
		file.SetTo(filePath.GetFullPath(), B_CREATE_FILE | B_READ_WRITE);
		file.WriteString("TYPE=Application\nLIB=B_BEOS_LIB_DIRECTORY/libsupc++.so\n");
		
		filePath = templatePath;
		filePath << "Kernel Driver/TEMPLATEINFO";
		file.SetTo(filePath.GetFullPath(), B_CREATE_FILE | B_READ_WRITE);
		file.WriteString("TYPE=Driver\n");
		
		filePath = templatePath;
		filePath << "Shared Library or Addon/TEMPLATEINFO";
		file.SetTo(filePath.GetFullPath(), B_CREATE_FILE | B_READ_WRITE);
		file.WriteString("TYPE=Shared\n");
		
		filePath = templatePath;
		filePath << "Static Library/TEMPLATEINFO";
		file.SetTo(filePath.GetFullPath(), B_CREATE_FILE | B_READ_WRITE);
		file.WriteString("TYPE=Static\n");
		
		file.Unset();
	}
}
Esempio n. 2
0
void InfoBox::GetFolder(BDirectory dir) {

	int32 c=dir.CountEntries();
	BEntry entry;
	
	if (c>0)
	for (int32 i=0; i<c; i++) {
		dir.GetNextEntry(&entry, true);
		if (entry.IsDirectory()) {
			folders++;
			GetFolder(BDirectory(&entry));
		}
		else
			files++;
	}
}
Esempio n. 3
0
status_t
PDirectory::GetProperty(const char *name, PValue *value, const int32 &index) const
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	BDirectory *backend = (BDirectory*)fBackend;
	if (str.ICompare("IsRoot") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsRootDirectory());
	else if (str.ICompare("EntryCount") == 0)
		((IntProperty*)prop)->SetValue(backend->CountEntries());
	else
	{
		return PNode::GetProperty(name, value, index);
	}

	return prop->GetValue(value);
}