示例#1
0
STRPTR GetDefInterfaceName(int argc, char **argv)
{
struct DiskObject *dobj;
struct WBStartup *wbs;
struct WBArg *wbarg;
STRPTR icname;
STRPTR iname;

	if (argc == 0)
	{
		wbs = (struct WBStartup *)argv;
		wbarg = wbs->sm_ArgList;
		icname = wbarg[0].wa_Name;
		CurrentDir(wbarg[0].wa_Lock);
	}
	else
		icname = argv[0];	

	if( !(dobj = GetDiskObject(icname)) )
	{
		CurrentDir(NULL);
		return(NULL);
	}	
		
	iname = FindToolType(dobj->do_ToolTypes, "INTERFACE");
	FreeDiskObject(dobj);
	CurrentDir(NULL);
	return(iname);
}
示例#2
0
文件: client.c 项目: Coderz333/cyassl
    int main(int argc, char** argv)
    {
        func_args args;

#ifdef HAVE_CAVIUM
        int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
        if (ret != 0)
            err_sys("Cavium OpenNitroxDevice failed");
#endif /* HAVE_CAVIUM */

        StartTCP();

        args.argc = argc;
        args.argv = argv;

        CyaSSL_Init();
#if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL)
        CyaSSL_Debugging_ON();
#endif
        if (CurrentDir("client") || CurrentDir("build"))
            ChangeDirBack(2);
  
#ifdef HAVE_STACK_SIZE
        StackSizeCheck(&args, client_test);
#else 
        client_test(&args);
#endif
        CyaSSL_Cleanup();

#ifdef HAVE_CAVIUM
        CspShutdown(CAVIUM_DEV_ID);
#endif
        return args.return_code;
    }
示例#3
0
文件: commands.c 项目: suborb/reelvdr
eOSState cCMDDir::New(void)
{
  MYDEBUG("Verzeichnis: Neu");
  cFileInfo *info = new cFileInfo(CurrentDir());
  if(!info->isWriteable())
  {
    MYDEBUG("Verzeichnis: Neu: Keine Berechtigung in %s", CurrentDir());
    OSD_ERRMSG(tr("no rights to create"));
  }
  else
  {
    State = csDirNew;
    SetCols(5);
    SetTitle(CurrentDir());
    SetDir();

    cMainMenuItem *mItem = (cMainMenuItem*)First();
    Ins(new cMenuEditStrItem(tr("New"), Dir, MaxFileName, trVDR(FileNameChars)),
        true,
        mItem);
    while(mItem)
    {
      mItem->SetSelectable(false);
      mItem = (cMainMenuItem*)Next(mItem);
    }
    Display();
    cOsdMenu::ProcessKey(kRight);
  }

  return osContinue;
}
示例#4
0
    int main(int argc, char** argv)
    {
        func_args args;

#ifdef HAVE_CAVIUM
        int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
        if (ret != 0)
            err_sys("Cavium OpenNitroxDevice failed");
#endif /* HAVE_CAVIUM */

        StartTCP();

        args.argc = argc;
        args.argv = argv;

        CyaSSL_Init();
#ifdef DEBUG_CYASSL
        CyaSSL_Debugging_ON();
#endif
        if (CurrentDir("echoclient") || CurrentDir("build"))
            ChangeDirBack(2);
        echoclient_test(&args);
        CyaSSL_Cleanup();

#ifdef HAVE_CAVIUM
        CspShutdown(CAVIUM_DEV_ID);
#endif
        return args.return_code;
    }
示例#5
0
static int simulated_chdir(char *name) {
  int result = -1;
  BPTR lock = Lock(name, ACCESS_READ);
  if (lock != NULL) {
    /* Change the current working directory (CWD) of the task
     */
    BPTR old_lock = CurrentDir(lock);

    /* Attempt to update internal buffer of the process.
       If we are not running in a process, but a plain task, this
       call does not cause any harm.
    */
    /* FIXME: What's the result of SetCurrentDirName() in a plain
       task? If it is FALSE, the below code won't work.
    */
    if (SetCurrentDirName(name)) {
      /* If this was successful, unlock `old_lock' because we
	 are not going to restore it later; this routine is one
	 of the few cases where such behavior is appropriate.
      */
      UnLock(old_lock);
      result = 0;
    }
    else {
      /* If it fails, restore the previous CWD and make the
	 whole routine fail.
      */
      CurrentDir(old_lock);
    }
  }
  return result;
}
示例#6
0
    int main(int argc, char** argv)
    {
        func_args args;

#ifdef HAVE_CAVIUM
        int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
        if (ret != 0)
            err_sys("Cavium OpenNitroxDevice failed");
#endif /* HAVE_CAVIUM */

        StartTCP();

        args.argc = argc;
        args.argv = argv;

        CyaSSL_Init();
#if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL)
        CyaSSL_Debugging_ON();
#endif
        if (CurrentDir("echoserver"))
            ChangeDirBack(2);
        else if (CurrentDir("Debug") || CurrentDir("Release"))
            ChangeDirBack(3);
        echoserver_test(&args);
        CyaSSL_Cleanup();

#ifdef HAVE_CAVIUM
        CspShutdown(CAVIUM_DEV_ID);
#endif
        return args.return_code;
    }
示例#7
0
文件: 7zUtils.c 项目: diegocr/7zUI
BOOL SwitchCurrentdir( STRPTR path, BPTR * where, BPTR * old )
{
	/* set the CurrentDir before extracting */
	
	if((*where) == 0)
	{
		// the function wasn't used previously, lock then
		
		(*where) = Lock( path, SHARED_LOCK );
		
		if(!(*where)) {
			PrintError("cannot lock selected drawer !?");
			return FALSE;
		}
		
		(*old) = CurrentDir((*where));
	}
	else
	{
		CurrentDir((*old));
		UnLock((*where));
	}
	
	return TRUE;
}
示例#8
0
文件: readwnd.c 项目: sba1/simplemail
/******************************************************************
 Save the contents of a given mail
*******************************************************************/
static void save_contents(struct Read_Data *data, struct mail *mail)
{
	if (!mail->num_multiparts)
	{
		if (MUI_AslRequestTags(data->file_req,
					mail->filename?ASLFR_InitialFile:TAG_IGNORE,mail->filename,
					TAG_DONE))
		{
			BPTR dlock;
			STRPTR drawer = data->file_req->fr_Drawer;

			mail_decode(mail);

			if ((dlock = Lock(drawer,ACCESS_READ)))
			{
				BPTR olock;
				BPTR fh;

				olock = CurrentDir(dlock);

				if ((fh = Open(data->file_req->fr_File, MODE_NEWFILE)))
				{
					Write(fh,mail->decoded_data,mail->decoded_len);
					Close(fh);
				}

				CurrentDir(olock);
				UnLock(dlock);
			}
		}
	}
}
示例#9
0
   void RenameFile (const std::string& srcName, const std::string& dstName, const std::string& path, bool removeExisting)
   {
      if (srcName.empty())      throw error::InvalidParam("No source file name specified!", ERROR_LOCATION);
      else if (dstName.empty()) throw error::InvalidParam("No destination file name specified!", ERROR_LOCATION);

      const std::string srcPath((path.empty()) ? (CurrentDir() + "\\" + srcName) : (path + "\\" + srcName));
      const std::string dstPath((path.empty()) ? (CurrentDir() + "\\" + dstName) : (path + "\\" + dstName));

      MoveFile(srcPath, dstPath, removeExisting);
   }
示例#10
0
ULONG NATDECLFUNC_5(GUI_Open, d0, ULONG, cpu, a0, UBYTE *, ProgramName, a1, struct WBArg *, IconName, a2, CONST_STRPTR, vstring, a6, struct DnetcLibrary *, LibBase)
{
	DECLARG_5(d0, ULONG, cpu, a0, UBYTE *, ProgramName, a1, struct WBArg *, IconName, a2, CONST_STRPTR, vstring, a6, struct DnetcLibrary *, LibBase)

	ULONG	sigmask;

	(void)ProgramName;
	(void)cpu;

	if (!LibBase->dobj)
	{
		if (IconName)
		{
			BPTR olddir;

			olddir = CurrentDir(IconName->wa_Lock);
			LibBase->dobj	= GetDiskObject(IconName->wa_Name);
			CurrentDir(olddir);
		}
	}

	sigmask	= 0;

	ObtainSemaphore(&LibBase->SemaphoreGUI);

	if (!LibBase->App)
	{
		Object	*app;

		strcpy(LibBase->Version, vstring);

		app	= NewObjectA(LibBase->AppMCC->mcc_Class, NULL, NULL);

		if (app)
		{
			LibBase->App			= app;
			LibBase->OwnerTask	= FindTask(NULL);

			DoMethod(app, MUIM_MyApplication_OpenMainWindow);

			sigmask	= 0xffff0000;
		}
	}

	ReleaseSemaphore(&LibBase->SemaphoreGUI);

	return sigmask;
}
示例#11
0
bool FileEnumerator::MoveNext()
{
  bool result = false;
  if (!m_StartupDir.empty())
  {
    if (m_CurrentNonRecursiveEnumerator == NULL)
      m_CurrentNonRecursiveEnumerator = new NonRecursiveFileEnumerator(NULL, m_StartupDir.c_str());
    // Enter directory if mode is recursive
    if ((m_Flags & DIRENUM_RECURSIVE_MODE) != 0 && 
      !m_CurrentNonRecursiveEnumerator->Bof() && 
      !m_CurrentNonRecursiveEnumerator->Eof() && 
      IsDir(CurrentPath()))
    {
      //std::string s = m_EntriesEnumerator->StartupDir();
      std::string s = JoinPath(CurrentDir(), m_CurrentNonRecursiveEnumerator->CurrentFileName());
      m_CurrentNonRecursiveEnumerator = new NonRecursiveFileEnumerator(m_CurrentNonRecursiveEnumerator, s.c_str());
    }
    // Find next entry
    result = m_CurrentNonRecursiveEnumerator->MoveNext();
    while (!result && m_CurrentNonRecursiveEnumerator->Parent() != NULL)
    {
      // Go to the parent directory
      NonRecursiveFileEnumerator* p = m_CurrentNonRecursiveEnumerator;
      m_CurrentNonRecursiveEnumerator = p->Parent();
      delete p;
      result = m_CurrentNonRecursiveEnumerator->MoveNext();
    }
    m_Flags &= ~DIRENUM_CURRENT_CACHED;
  }
  return result;
}
示例#12
0
文件: commands.c 项目: suborb/reelvdr
void cCMDMove::Build(char *dir)
{
  MYDEBUG("Verzeichnis: Move: Erstelle Verzeichnisliste: %s", dir);
  if(!dir)
    dir = CurrentDir();

  Clear();

  cDirHandling *DirHand = new cDirHandling(this, this);
  SetCurrent(Get(DirHand->Build(dir, true)));
  delete(DirHand);

  if(Count())
  {
    cMainMenuItem *item = (cMainMenuItem*)First();
    while(item)
    {
      if(!strcasecmp(item->FileName(), File))
      {
        Del(item->Index());
        break;
      }
      item = (cMainMenuItem*)Next(item);
    }
  }

  Display();
  SetHelp();
}
示例#13
0
void __exitcommandline(void)
{
  struct WBStartup *wbs=_WBenchMsg;

  if (wbs!=NULL)
  { BPTR file;
    if((file=window)!=0) {
      SelectOutput(output);
      SelectInput(input);
      PPCClose(file);
    }
    if(wbs->sm_ArgList!=NULL) { // set original lock
      UnLock(CurrentDir(cd));
    }
  }
  else
  {
    char *cl=cline;

    if(cl!=NULL)
    { char **av=__argv;

      if(av!=NULL)
      { 
        PPCFreeVec(av);
      }
      PPCFreeVec(cl);
    }
  }
}
示例#14
0
//-------------------------------------------------------------
// Pre     : If bCreateIntermediates is TRUE, create all eventually
//           missing parent directories too
// Post    : Return TRUE on success
// Task    : Create new directory
//-------------------------------------------------------------
bool CPath::DirectoryCreate(bool bCreateIntermediates /*= TRUE*/)
{
    std::string	PathText;
    bool	bSuccess;

    GetDriveDirectory(PathText);
    StripTrailingBackslash(PathText);
    bSuccess =::CreateDirectory(PathText.c_str(),NULL) != 0;
    if(!bSuccess)
    {
        CPath CurrentDir(CPath::CURRENT_DIRECTORY);
        bSuccess = ChangeDirectory() != 0;
        CurrentDir.ChangeDirectory();
    }

    if(!bSuccess && bCreateIntermediates)
    {
        std::string::size_type nDelimiter =PathText.rfind(DIRECTORY_DELIMITER);
        if(nDelimiter == std::string::npos)
            return FALSE;

        PathText.resize(nDelimiter + 1);
        CPath SubPath(PathText);

        if (SubPath.DirectoryCreate())
            return DirectoryCreate(false);
        else
            return FALSE;
    }

    return bSuccess;
}
示例#15
0
/* This function changes the current directory to the wolfssl root */
static void ChangeDirToRoot(void)
{
    /* Normal Command Line=_build, Visual Studio=testsuite */
    if (CurrentDir("testsuite") || CurrentDir("_build")) {
        ChangeDirBack(1);
    }

    /* Xcode: To output application to correct location: */
    /* 1. Xcode->Preferences->Locations->Locations */
    /* 2. Derived Data Advanced -> Custom */
    /* 3. Relative to Workspace, Build/Products */
    /* Build/Products/Debug or Build/Products/Release */
    else if (CurrentDir("Debug") || CurrentDir("Release")) {
    ChangeDirBack(5);
    }
}
void __exitcommandline(void)
{ struct WBStartup *wbs=_WBenchMsg;

  if(wbs!=NULL)
  { BPTR file;
    if((file=window)!=0l)
      Close(file);
    if(wbs->sm_ArgList!=NULL) /* set original lock */
      UnLock(CurrentDir(cd));
  }else
  { char *cl=cline;

    if(cl!=NULL)
    { char **av=__argv;

      if(av!=NULL)
      { 
        if(*av!=NULL)
          FreeVec(*av);
        FreeVec(av);
      }
      FreeVec(cl);
    }
  }
}
示例#17
0
bool removeDirectoryRecursively(const QString& Path)
{
  bool Res = true;
  QDir CurrentDir(Path);

  if (CurrentDir.exists(Path))
  {
    for (QFileInfo Info : CurrentDir.entryInfoList(QDir::NoDotAndDotDot |
                                                   QDir::System |
                                                   QDir::Hidden  |
                                                   QDir::AllDirs |
                                                   QDir::Files,
                                                   QDir::DirsFirst))
    {
      if (Info.isDir())
      {
        Res = removeDirectoryRecursively(Info.absoluteFilePath());
      }
      else
      {
        Res = QFile::remove(Info.absoluteFilePath());
      }

      if (!Res)
      {
        return Res;
      }
    }
    Res = CurrentDir.rmdir(Path);
  }

  return Res;
}
示例#18
0
const char *Q_FindFirstFile (const char *path, const char *pattern)
{
	BPTR newdir;

	if (apath)
		COM_Error ("FindFirst without FindClose");

	apath = (struct AnchorPath *) AllocVec (sizeof(struct AnchorPath) + PATH_SIZE, MEMF_CLEAR);
	if (!apath)
		return NULL;

	apath->ap_Strlen = PATH_SIZE;
	apath->ap_BreakBits = 0;
	apath->ap_Flags = 0;  /* APF_DOWILD */

	newdir = Lock((const STRPTR) path, SHARED_LOCK);
	if (newdir)
		oldcurrentdir = CurrentDir(newdir);
	else
	{
		FreeVec(apath);
		apath = NULL;
		return NULL;
	}

	pattern_str = pattern_helper (pattern);

	if (MatchFirst((const STRPTR) pattern_str, apath) == 0)
	{
	    if (apath->ap_Info.fib_DirEntryType < 0)
		return (const char *) (apath->ap_Info.fib_FileName);
	}

	return Q_FindNextFile();
}
示例#19
0
文件: commands.c 项目: suborb/reelvdr
eOSState cCMDDir::Edit(cMainMenuItem *mItem)
{
  MYDEBUG("Verzeichnis: Edit: %s", mItem->FileName());
  cFileInfo *info = new cFileInfo(mItem->FileName());
  if(!info->isWriteable())
  {
    DELETENULL(info);
    info = new cFileInfo(CurrentDir());
    if(!info->isWriteable())
    {
      MYDEBUG("Verzeichnis: Edit: Keine Rechte");
      OSD_ERRMSG(tr("no rights to rename"));
      DELETENULL(info);
      return osContinue;
    }
  }
  DELETENULL(info);
  info = new cFileInfo(mItem->FileName());
  SetDir(info->FileName());
  DELETENULL(info);
  State = csDirEdit;
  SetCols(11);
  SetTitle(CurrentDir());

  cMainMenuItem *dmItem = NULL;
  mItem = (cMainMenuItem*)First();
  while(mItem)
  {
    if(!strcasecmp(mItem->FileName(), LastSelDir()))
    {
      MYDEBUG("Verzeichnis: Edit: Item gefunden: %s", mItem->FileName());
      Ins(new cMenuEditStrItem(tr("Rename"), Dir, MaxFileName, trVDR(FileNameChars)),
          true,
          mItem);
      dmItem = mItem;
    }
    mItem->SetSelectable(false);
    mItem = (cMainMenuItem*)Next(mItem);
  }

  if(dmItem)
    Del(dmItem->Index());
  Display();
  cOsdMenu::ProcessKey(kRight);

  return osContinue;
}
示例#20
0
文件: commands.c 项目: suborb/reelvdr
eOSState cCMDMove::ProcessKey(eKeys Key)
{
  cMainMenuItem *mItem = (cMainMenuItem*)Get(Current());
  cDirHandling *DirHand = NULL;
  cFileMoveThread *move = NULL;

  switch(Key)
  {
    case kUp:
    case kUp|k_Repeat:
    case kDown:
    case kDown|k_Repeat:
      cOsdMenu::ProcessKey(Key);
      SetHelp();
      mItem = (cMainMenuItem*)Get(Current());
      if(mItem)
        LastSelDir(mItem->FileName());
      return osContinue;
      break;
    case kOk:
      DirHand = new cDirHandling(this, this);
      DirHand->ProcessKey(mItem);
      DELETENULL(DirHand);
      Build();
      break;
    case kBlue:
      MYDEBUG("Verzeichnis: Move: Verschiede in: %s", CurrentDir());
      move = new cFileMoveThread(File, CurrentDir());
      if(move->OK())
      {
        MYDEBUG("Verzeichnis: Move: Erfolgreich");
        move->Start();
        cCondWait::SleepMs(1 * 500);
        OsdObject->SetState(mmsReInit);
      }
      else
        DELETENULL(move);
      if(!Dir && !Direct)
        cRemote::Put(kBack);
      return osBack;
      break;
    default:
      break;
  }

  return cOsdMenu::ProcessKey(Key);
}
示例#21
0
void
myexit()
{
   if (XSaveLockValid) {
      CurrentDir(XSaveLock);
      XSaveLockValid = 0;
   }
}
示例#22
0
TempCurrentDir::TempCurrentDir(const char* dir)
{
  if (!IsEmpty(dir))
  {
    m_SavedDir = CurrentDir();
    SetCurrentDir(dir);
  }
}
示例#23
0
const char* FileEnumerator::CurrentPath()
{
  if ((m_Flags & DIRENUM_CURRENT_CACHED) == 0)
  {
    m_Current = JoinPath(CurrentDir(), CurrentFileName());
    m_Flags |= DIRENUM_CURRENT_CACHED;
  }
  return m_Current.c_str();
}
示例#24
0
文件: chdir.c 项目: wtxpwh/libnix
void __initchdir(void)
{
    BPTR fl;

    if (!(fl=Lock("",SHARED_LOCK)))
        exit(20);
    oldlock=CurrentDir(fl);
    havelock=1;
}
示例#25
0
// Delete any temporary files
void delete_temp_files(struct DateStamp *last)
{
	struct AnchorPath *anchor;
	BPTR old,lock;

	// Lock T: and cd
	if ((lock=Lock("t:",ACCESS_READ)))
	{
		// CD to t:
		old=CurrentDir(lock);

		// Allocate an anchor
		if ((anchor=AllocVec(sizeof(struct AnchorPath),MEMF_CLEAR)))
		{
			short error;
			struct FileInfoBlock fibcopy;

			// See if any script files already exist
			error=MatchFirst("T:dopus#?tmp#?",anchor);
			while (!error)
			{
				// Copy fib
				fibcopy=anchor->ap_Info;

				// Get next
				error=MatchNext(anchor);

				// Check datestamp
				if (!last ||
					CompareDates(&fibcopy.fib_Date,last)>=0)
				{
					// Try to delete file
					DeleteFile(fibcopy.fib_FileName);
				}
			}

			// Cleanup anchor
			MatchEnd(anchor);
			FreeVec(anchor);
		}

		UnLock(CurrentDir(old));
	}
}
    int main(int argc, char** argv)
    {
        func_args args;

        StartTCP();

        args.argc = argc;
        args.argv = argv;

        CyaSSL_Init();
#ifdef DEBUG_CYASSL
        CyaSSL_Debugging_ON();
#endif
        if (CurrentDir("echoclient") || CurrentDir("build"))
            ChangeDirBack(2);
        echoclient_test(&args);
        CyaSSL_Cleanup();

        return args.return_code;
    }
示例#27
0
int unit_test(int argc, char** argv)
{
    int ret;

    (void)argc;
    (void)argv;
    printf("starting unit tests...\n");

#ifdef HAVE_CAVIUM
    ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
    if (ret != 0)
        err_sys("Cavium OpenNitroxDevice failed");
#endif /* HAVE_CAVIUM */

#ifndef WOLFSSL_TIRTOS
    if (CurrentDir("tests") || CurrentDir("_build"))
        ChangeDirBack(1);
    else if (CurrentDir("Debug") || CurrentDir("Release"))
        ChangeDirBack(3);
#endif

    ApiTest();

    if ( (ret = HashTest()) != 0){
        printf("hash test failed with %d\n", ret);
        return ret;
    }

#ifndef SINGLE_THREADED
    if ( (ret = SuiteTest()) != 0){
        printf("suite test failed with %d\n", ret);
        return ret;
    }
#endif

#ifdef HAVE_CAVIUM
        CspShutdown(CAVIUM_DEV_ID);
#endif

    return 0;
}
示例#28
0
int main(int argc, char** argv)
{
    func_args server_args;

    server_args.argc = argc;
    server_args.argv = argv;

    if (CurrentDir("testsuite") || CurrentDir("_build"))
        ChangeDirBack(1);
    else if (CurrentDir("Debug") || CurrentDir("Release"))
        ChangeDirBack(3);          /* Xcode->Preferences->Locations->Locations*/
                                   /* Derived Data Advanced -> Custom  */
                                   /* Relative to Workspace, Build/Products */
                                   /* Debug or Release */

    ctaocrypt_test(&server_args);
    if (server_args.return_code != 0) return server_args.return_code;

    printf("\nAll tests passed!\n");
    return EXIT_SUCCESS;
}
示例#29
0
void Q_FindClose (void)
{
	if (apath == NULL)
		return;
	MatchEnd(apath);
	FreeVec(apath);
	UnLock(CurrentDir(oldcurrentdir));
	oldcurrentdir = 0;
	apath = NULL;
	free (pattern_str);
	pattern_str = NULL;
}
void UBTDecorator_KeepInCone::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
{
	TNodeInstanceMemory* DecoratorMemory = reinterpret_cast<TNodeInstanceMemory*>(NodeMemory);
	FVector CurrentDir(1.0f, 0, 0);
	
	if (CalculateCurrentDirection(OwnerComp, CurrentDir))
	{
		const float Angle = DecoratorMemory->InitialDirection.CosineAngle2D(CurrentDir);
		if (Angle < ConeHalfAngleDot || (IsInversed() && Angle > ConeHalfAngleDot))
		{
			OwnerComp.RequestExecution(this);
		}
	}
}