JBoolean
SyGApplication::RestoreProgramState()
{
	JPtrArray<JString> children(JPtrArrayT::kDeleteAll);
	if (!(SyGGetPrefsMgr())->RestoreProgramState(&children))
		{
		return kJFalse;
		}

	const JSize count = children.GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		const JString* str = children.NthElement(i);
		OpenDirectory(*str, NULL, NULL, kJFalse, kJFalse);
		}

	if (itsWindowList->IsEmpty())
		{
		JString path;
		if (!JGetHomeDirectory(&path) || !JFSFileTreeNode::CanHaveChildren(path))
			{
			path = JGetRootDirectory();
			}
		OpenDirectory(path);

		SyGTreeDir* dir;
		if (SyGGetTrashDirectory(&path, kJFalse) &&
			OpenDirectory(path, &dir))
			{
			(dir->GetWindow())->Iconify();
			}
		}

	return kJTrue;
}
struct dirent* GetFileDirent(char* path, char* name)
{
	DIR* dirp = OpenDirectory(path);
	struct dirent* dp;
	if(NULL == dirp) return NULL;
	do {
		errno = 0;
		if ((dp = ReadDirectory(dirp)) != NULL) 
		{
			if (strcmp(dp->d_name, name) == 0)
			{
				CloseDirectory(dirp);
				return dp;
			}	
		}	
	} while (dp != NULL);

	if (errno != 0)
	{
		fprintf(stderr, "Error while searching for file %s in directory %s\n", name, path);
		fprintf(stderr, "Error = %s\n", strerror(errno));
	}
	CloseDirectory(dirp);
	return NULL;
}
Esempio n. 3
0
QDirectory::QDirectory(QMDS * pMds, const char * szDirName) :
	m_pMds( pMds),
	m_strDirName( szDirName )
{
	memset( &m_hDb, 0, sizeof(m_hDb) );
	OpenDirectory();
}
Esempio n. 4
0
CSSM_RETURN QDirectory::Open(QMDS *pMds, const char *szDirName)
{
  ASSERTVALID();

  m_pMds = pMds;
  m_strDirName = szDirName;
  return OpenDirectory();
}
Esempio n. 5
0
status_t
DirectoryView::OpenDirectory(const char *pathname)
{
	BEntry entry(pathname);
	Directory dir(entry);

	status_t ret = OpenDirectory(&dir);

	return ret;
}
JBoolean
SyGApplication::OpenDirectory()
{
	JString path;
	if ((SyGGetChooseSaveFile())->ChooseRPath("Select path", NULL, NULL, &path))
		{
		return OpenDirectory(path);
		}
	else
		{
		return kJFalse;
		}
}
Esempio n. 7
0
DirIterator::DirIterator(const std::string& path, 
            const std::function<bool(const std::string&)>& filter,
            ValueType valueType) :
  path(path),
  filter(filter),
  valueType(valueType)
{
  OpenDirectory();
  if (filter)
  {
    DirIterator end;
    while (*this != end && filter(**this))
    {
      ++(*this);
    }
  }
}
JBoolean
SVNWDManager::NewBrowser
	(
	SVNMainDirector** dir
	)
{
	JString path;
	if ((JXGetChooseSaveFile())->ChooseRWPath("", JGetString(kNewBrowserInstrID),
											  NULL, &path))
		{
		*dir = OpenDirectory(path);
		return kJTrue;
		}
	else
		{
		*dir = NULL;
		return kJFalse;
		}
}
Esempio n. 9
0
bool CleanFiles(HWND window) {
  auto config = ReadConfig(OpenConfigFile());

  auto keep_count = config["keep_count"].get_int64();
  if (keep_count <= 0)
    return false;

  auto path_ns = config["path_to_clean"].get_string();
  if (path_ns.empty())
    return false;

  plx::FilePath path(std::wstring(path_ns.begin(), path_ns.end()));
  auto dir = OpenDirectory(path);
  if (dir.status() != (plx::File::directory | plx::File::existing))
    return false;

  if (!EnumAndClean(plx::FilesInfo::FromDir(dir), path, keep_count))
    return false;

  int timer_ms = 1000 * plx::To<int>(config["check_frequency"].get_int64());
  ::SetTimer(window, 1007, timer_ms , nullptr);
  return true;
}
void
SyGApplication::OpenShortcut
	(
	const JIndex index
	)
{
	const JString* path = NULL;

	JString trashDir;
	const JBoolean hasTrashDir = SyGGetTrashDirectory(&trashDir, kJFalse);

	const JSize mpCount         = itsMountPointList->GetElementCount();
	const JIndex shortcutOffset = mpCount + (hasTrashDir ? 1 : 0);
	if (index <= mpCount)
		{
		path = (itsMountPointList->GetElement(index)).path;
		}
	else if (hasTrashDir && index == mpCount+1)
		{
		path = &trashDir;
		}
	else
		{
		path = itsShortcutList->NthElement(index - shortcutOffset);
		}

	if (!OpenDirectory(*path, NULL, NULL, kJTrue, kJFalse) && index > shortcutOffset)
		{
		JString msg = "\"";
		msg += *path;
		msg += "\" does not exist or is unreadable.  Do you want to remove this shortcut?";
		if (JGetUserNotification()->AskUserYes(msg))
			{
			itsShortcutList->DeleteElement(index - shortcutOffset);
			}
		}
}
 // This takes all the names of all the files in the directory given by
 // inputDirectory which end in inputSuffix, and places each in a
 // FilenameTriple with the placeholder filename given by replacing
 // inputSuffix with placeholderSuffix, replacing the directory path with
 // placeholderDirectory, and the same for the output file using
 // outputSuffix and outputDirectory.
 inline void
 FilePlaceholderManager::PrepareFilenames( std::string const& inputDirectory,
                                      std::string const& placeholderDirectory,
                                          std::string const& outputDirectory )
 {
   std::vector< std::string > validBaseFilenames;
   OpenDirectory( inputDirectory );
   while( ReadNextFilenameInDirectory() )
   {
     if( currentFilename.compare( ( currentFilename.size()
                                    - inputSuffix.size() ),
                                  inputSuffix.size(),
                                  inputSuffix ) == 0 )
     {
       validBaseFilenames.push_back( currentFilename.substr( 0,
                          ( currentFilename.size() - inputSuffix.size() ) ) );
     }
   }
   PrepareFilenames( validBaseFilenames,
                     inputDirectory,
                     placeholderDirectory,
                     outputDirectory );
   CloseDirectory();
 }
Esempio n. 12
0
void updateFilebrowser() {
	if(kDown & KEY_SELECT) {
		currentViewer = new SettingsViewer();
		currentViewer->Init();
	}
	
	//Find a better way to cycle through these
	if(kDown & KEY_L) {
		switch(mode) {
			case SELECT:
				mode = DELETE;
				break;
			case DELETE:
				mode = COPY;
				break;
			case COPY:
				mode = PASTE;
				break;
			case PASTE:
				mode = SELECT;
				break;
		}
	}
	
	//Mode action
	if(kDown & KEY_X) {
		switch(mode) {
			case SELECT:
			{
				selectedEntries[(currentPath + entries[currentSelection]->name)] = !selectedEntries[(currentPath + entries[currentSelection]->name)];
				printf("Toggled selection for: %s\n", (currentPath + entries[currentSelection]->name).c_str());
			}
			break;
		}
	}
	
	if(kDown & KEY_UP) {
		//Easy fix until i'm bothered to fix the issue
		if(currentSelection < 0 | viewOffset < 0) {
			currentSelection = 0;
			viewOffset = 0;
		}
		
		if(viewOffset != 0) {
			viewOffset -= 1;
			currentSelection -= 1;
		}
		
		if(currentSelection != 0) {
			currentSelection -= 1;
		}
	}
	
	if(kDown & KEY_DOWN) {
		//Failsafe to prevent crashing
		if(currentSelection > entries.size()) {
			currentSelection = 0;
			viewOffset = 0;
		}
		
		if(currentSelection == 13 + viewOffset) {
			viewOffset += 1;
		}
		
		if(currentSelection != entries.size() - 1) {
			currentSelection += 1;
		}
	}
	
	if(kDown & KEY_A) {
		if(!entries[currentSelection]->isDirectory) {
			ViewFile(entries[currentSelection]->name);
		} else {
			OpenDirectory(entries[currentSelection]->name, true);
		}
	}
	
	if(kDown & KEY_B) {
		if(currentPath != "./")
			UpDirectory();
	}
}
Esempio n. 13
0
void
TFilePanel::MessageReceived(BMessage* message)
{
	entry_ref ref;

	switch (message->what) {
		case B_REFS_RECEIVED:
			// item was double clicked in file panel (PoseView)
			if (message->FindRef("refs", &ref) == B_OK) {
				BEntry entry(&ref, true);
				if (entry.InitCheck() == B_OK) {
					// Double-click on dir or link-to-dir ALWAYS opens the
					// dir. If more than one dir is selected, the first is
					// entered.
					if (entry.IsDirectory()) {
						entry.GetRef(&ref);
						bool isDesktop = SwitchDirToDesktopIfNeeded(ref);

						PoseView()->SetIsDesktop(isDesktop);
						entry.SetTo(&ref);
						PoseView()->SwitchDir(&ref);
						SwitchDirMenuTo(&ref);
					} else {
						// Otherwise, we have a file or a link to a file.
						// AdjustButton has already tested the flavor;
						// all we have to do is see if the button is enabled.
						BButton* button = dynamic_cast<BButton*>(
							FindView("default button"));
						if (button == NULL)
							break;

						if (IsSavePanel()) {
							int32 count = 0;
							type_code type;
							message->GetInfo("refs", &type, &count);

							// Don't allow saves of multiple files
							if (count > 1) {
								ShowCenteredAlert(
									B_TRANSLATE(
										"Sorry, saving more than one "
										"item is not allowed."),
									B_TRANSLATE("Cancel"));
							} else {
								// if we are a savepanel, set up the
								// filepanel correctly then pass control
								// so we follow the same path as if the user
								// clicked the save button

								// set the 'name' fld to the current ref's
								// name notify the panel that the default
								// button should be enabled
								SetSaveText(ref.name);
								SelectionChanged();

								HandleSaveButton();
							}
							break;
						}

					  	// send handler a message and close
						BMessage openMessage(*fMessage);
						for (int32 index = 0; ; index++) {
					  		if (message->FindRef("refs", index, &ref) != B_OK)
								break;
							openMessage.AddRef("refs", &ref);
					  	}
						OpenSelectionCommon(&openMessage);
					}
				}
			}
			break;

		case kSwitchDirectory:
		{
			entry_ref ref;
			// this comes from dir menu or nav menu, so switch directories
			if (message->FindRef("refs", &ref) == B_OK) {
				BEntry entry(&ref, true);
				if (entry.GetRef(&ref) == B_OK)
					SetTo(&ref);
			}
			break;
		}

		case kSwitchToHome:
		{
			BPath homePath;
			entry_ref ref;
			if (find_directory(B_USER_DIRECTORY, &homePath) != B_OK
				|| get_ref_for_path(homePath.Path(), &ref) != B_OK) {
				break;
			}

			SetTo(&ref);
			break;
		}

		case kAddCurrentDir:
		{
			BPath path;
			if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true)
					!= B_OK) {
				break;
			}

			path.Append(kGoDirectory);
			BDirectory goDirectory(path.Path());

			if (goDirectory.InitCheck() == B_OK) {
				BEntry entry(TargetModel()->EntryRef());
				entry.GetPath(&path);

				BSymLink link;
				goDirectory.CreateSymLink(TargetModel()->Name(), path.Path(),
					&link);
			}
			break;
		}

		case kEditFavorites:
		{
			BPath path;
			if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true)
					!= B_OK) {
				break;
			}

			path.Append(kGoDirectory);
			BMessenger msgr(kTrackerSignature);
			if (msgr.IsValid()) {
				BMessage message(B_REFS_RECEIVED);
				entry_ref ref;
				if (get_ref_for_path(path.Path(), &ref) == B_OK) {
					message.AddRef("refs", &ref);
					msgr.SendMessage(&message);
				}
			}
			break;
		}

		case kCancelButton:
			PostMessage(B_QUIT_REQUESTED);
			break;

		case kResizeToFit:
			ResizeToFit();
			break;

		case kOpenDir:
			OpenDirectory();
			break;

		case kOpenParentDir:
			OpenParent();
			break;

		case kDefaultButton:
			if (fIsSavePanel) {
				if (PoseView()->IsFocus()
					&& PoseView()->SelectionList()->CountItems() == 1) {
					Model* model = (PoseView()->SelectionList()->
						FirstItem())->TargetModel();
					if (model->ResolveIfLink()->IsDirectory()) {
						PoseView()->CommitActivePose();
						PoseView()->OpenSelection();
						break;
					}
				}

				HandleSaveButton();
			} else
				HandleOpenButton();
			break;

		case B_OBSERVER_NOTICE_CHANGE:
		{
			int32 observerWhat;
			if (message->FindInt32("be:observe_change_what", &observerWhat)
					== B_OK) {
				switch (observerWhat) {
					case kDesktopFilePanelRootChanged:
					{
						bool desktopIsRoot = true;
						if (message->FindBool("DesktopFilePanelRoot",
								&desktopIsRoot) == B_OK) {
							TrackerSettings().
								SetDesktopFilePanelRoot(desktopIsRoot);
						}
						SetTo(TargetModel()->EntryRef());
						break;
					}
				}
			}
			break;
		}

		default:
			_inherited::MessageReceived(message);
			break;
	}
}
Esempio n. 14
0
DirIterator::DirIterator(const std::string& path, ValueType valueType) :
  path(path),
  valueType(valueType)
{
  OpenDirectory();
}
Esempio n. 15
0
DirIterator& DirIterator::Rewind()
{
  OpenDirectory();
  return *this;
}
Esempio n. 16
0
/***************************************************************************
 *  M A I N
 *
 ***************************************************************************/
int main (int argc, char *argv[])
{
 #ifdef HW_RVL
  /* enable 64-byte fetch mode for L2 cache */
  L2Enhance();
  
  /* initialize DI interface */
  DI_UseCache(0);
  DI_Init();

  sprintf(osd_version, "%s (IOS %d)", VERSION, IOS_GetVersion());
#else
  sprintf(osd_version, "%s (GCN)", VERSION);
#endif

  /* initialize video engine */
  gx_video_Init();

#ifndef HW_RVL
  /* initialize DVD interface */
  DVD_Init();
#endif

  /* initialize input engine */
  gx_input_Init();

  /* initialize FAT devices */
  int retry = 0;
  int fatMounted = 0;

  /* try to mount FAT devices during 3 seconds */
  while (!fatMounted && (retry < 12))
  {
    fatMounted = fatInitDefault();
    usleep(250000);
    retry++;
  }

  if (fatMounted)
  {
    /* base directory */
    char pathname[MAXPATHLEN];
    sprintf (pathname, DEFAULT_PATH);
    DIR *dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);

    /* default SRAM & Savestate files directories */ 
    sprintf (pathname, "%s/saves",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/saves/md",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/saves/ms",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/saves/gg",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/saves/sg",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/saves/cd",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);

    /* default Snapshot files directories */ 
    sprintf (pathname, "%s/snaps",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/snaps/md",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/snaps/ms",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/snaps/gg",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/snaps/sg",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/snaps/cd",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);

    /* default Cheat files directories */ 
    sprintf (pathname, "%s/cheats",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/cheats/md",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/cheats/ms",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/cheats/gg",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/cheats/sg",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
    sprintf (pathname, "%s/cheats/cd",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);

    /* default BIOS ROM files directories */ 
    sprintf (pathname, "%s/bios",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);

    /* default LOCK-ON ROM files directories */ 
    sprintf (pathname, "%s/lock-on",DEFAULT_PATH);
    dir = opendir(pathname);
    if (dir) closedir(dir);
    else mkdir(pathname,S_IRWXU);
  }

  /* initialize sound engine */
  gx_audio_Init();

  /* initialize genesis plus core */
  history_default();
  config_default();
  init_machine();

  /* auto-load last ROM file */
  if (config.autoload)
  {
    SILENT = 1;
    if (OpenDirectory(TYPE_RECENT, -1))
    {
      if (LoadFile(0))
      {
        reloadrom();
        gx_video_Start();
        gx_audio_Start();
        ConfigRequested = 0;
      }
    }
    SILENT = 0;
  }

  /* show disclaimer */
  if (ConfigRequested)
  {
    legal();
  }

#ifdef HW_RVL
  /* power button callback */
  SYS_SetPowerCallback(PowerOff_cb);
#endif

  /* reset button callback */
  SYS_SetResetCallback(Reset_cb);

  /* main emulation loop */
  run_emulation();

  /* we should never return anyway */
  return 0;
}
Esempio n. 17
0
 Aws::UniquePtr<Directory> Directory::Descend(const DirectoryEntry& directoryEntry)
 {
     assert(directoryEntry.fileType != FileType::File);
     return OpenDirectory(directoryEntry.path, directoryEntry.relativePath);
 }
Esempio n. 18
0
 DirectoryTree::DirectoryTree(const Aws::String& path)
 {
     m_dir = OpenDirectory(path);
 }
Esempio n. 19
0
 void DirectoryTree::TraverseDepthFirst(const DirectoryEntryVisitor& visitor, bool postOrderTraversal)
 {
     TraverseDepthFirst(*m_dir, visitor, postOrderTraversal);
     m_dir = OpenDirectory(m_dir->GetPath());
 }
Esempio n. 20
0
 void DirectoryTree::TraverseBreadthFirst(const DirectoryEntryVisitor& visitor)
 {
     TraverseBreadthFirst(*m_dir, visitor);
     m_dir = OpenDirectory(m_dir->GetPath());
 }