예제 #1
0
파일: filedlg.cpp 프로젝트: gahr/fxite
/*
  Fox doesn't automatically handle MS-Windows shortcut files, so...
  Iterate through each filename in the file dialog's getFilenames() list,
  if any of them are shortcut (*.lnk) files, dereference the link and
  make the string point to the "real" disk file. If we have multiple files,
  remove any links that point to a directory. But if we only have one string
  in the list, and the string is a link pointing to a directory, we will
  dereference it so the dialog can change into that folder.
*/
static void FixupShortcuts(FXWindow*w, FXString* filenames)
{
  if (!filenames) return;
  FXString* fn;
  FXString* tail=filenames;
  FXuint count=0;
  for (fn=filenames; !fn->empty(); fn++) {
    if (IsLinkExt(*fn)) {
      char*tmp=NULL;
      if (ReadShortcut(&tmp, fn->text())) {
        *fn=tmp;
      } else {
        FXMessageBox::error(w,MBOX_OK,_("Error in shortcut"),"%s\n%s",fn->text(),tmp);
      }
      free(tmp);
    }
    tail=fn;
    count++;
  }
  if (count>1) {
    for (fn=filenames; !fn->empty(); fn++) {
      if (FXStat::isDirectory(*fn)) {
        *fn=tail->text();
        *tail="";
        tail--;
      }
    }
  }
}
예제 #2
0
long
MembersFrame::onApplyChanges(FXObject*,FXSelector,void*)
{
  FXFoldingItem *mitem = memberslist->findItemByData((void*)editedmember);
  FXString newname = nametf->getText();
  FXString newlogin = logintf->getText();

  if (mitem) {
    newname.trim();
    newlogin.trim();
    CCL_member_tarif_set(editedmember,tarifset);
    if (!newname.empty() && -1 == CCL_member_find(newname.text()))
      CCL_member_name_set(editedmember,nametf->getText().text());
    CCL_member_email_set(editedmember,emailtf->getText().text());
    CCL_member_other_set(editedmember,phonetf->getText().text());
    if (newlogin.empty() && CCL_data_key_exists(CCL_DATA_MEMBER,editedmember,
						"login_name"))
      CCL_data_key_delete(CCL_DATA_MEMBER,editedmember,"login_name");
    else if (-1 == CCL_data_find_by_key_sval(CCL_DATA_MEMBER,"login_name",
					     newlogin.text()))
      CCL_data_set_string(CCL_DATA_MEMBER,editedmember,"login_name",
			  newlogin.text());
    mitem->setText(FXStringVal((FXint)editedmember) + "\t" + CCL_member_name_get(editedmember));
    memberslist->updateItem(mitem);
  }
#ifdef DEBUG
  printf("onApplyChanges(): Apply Changes Button was pressed\n");
#endif
  
  return 1;
}
예제 #3
0
// Get home directory for a given user
FXString FXSystem::getUserDirectory(const FXString& user){
#ifndef WIN32
#if defined(FOX_THREAD_SAFE) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
  struct passwd pwdresult,*pwd;
  char buffer[1024];
  if(user.empty()){
    register const FXchar* str;
    if((str=getenv("HOME"))!=NULL) return str;
    if((str=getenv("USER"))!=NULL || (str=getenv("LOGNAME"))!=NULL){
      if(getpwnam_r(str,&pwdresult,buffer,sizeof(buffer),&pwd)==0 && pwd) return pwd->pw_dir;
      }
    if(getpwuid_r(getuid(),&pwdresult,buffer,sizeof(buffer),&pwd)==0 && pwd) return pwd->pw_dir;
    return PATHSEPSTRING;
    }
  if(getpwnam_r(user.text(),&pwdresult,buffer,sizeof(buffer),&pwd)==0 && pwd) return pwd->pw_dir;
  return PATHSEPSTRING;
#else
  register struct passwd *pwd;
  if(user.empty()){
    register const FXchar* str;
    if((str=getenv("HOME"))!=NULL) return str;
    if((str=getenv("USER"))!=NULL || (str=getenv("LOGNAME"))!=NULL){
      if((pwd=getpwnam(str))!=NULL) return pwd->pw_dir;
      }
    if((pwd=getpwuid(getuid()))!=NULL) return pwd->pw_dir;
    return PATHSEPSTRING;
    }
  if((pwd=getpwnam(user.text()))!=NULL) return pwd->pw_dir;
  return PATHSEPSTRING;
#endif
#else
  if(user.empty()){
    register const FXchar *str1,*str2;
    FXchar home[MAXPATHLEN];
    DWORD size=MAXPATHLEN;
    HKEY hKey;
    LONG result;
    if((str1=getenv("USERPROFILE"))!=NULL) return str1; // Daniël Hörchner <*****@*****.**>
    if((str1=getenv("HOME"))!=NULL) return str1;
    if((str2=getenv("HOMEPATH"))!=NULL){      // This should be good for WinNT, Win2K according to MSDN
      if((str1=getenv("HOMEDRIVE"))==NULL) str1="c:";
      strncpy(home,str1,MAXPATHLEN);
      strncat(home,str2,MAXPATHLEN);
      return home;
      }
//  FXchar buffer[MAX_PATH]
//  if(SHGetFolderPath(NULL,CSIDL_PERSONAL|CSIDL_FLAG_CREATE,NULL,O,buffer)==S_OK){
//    return buffer;
//    }
    if(RegOpenKeyExA(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",0,KEY_READ,&hKey)==ERROR_SUCCESS){
      result=RegQueryValueExA(hKey,"Personal",NULL,NULL,(LPBYTE)home,&size);  // Change "Personal" to "Desktop" if you want...
      RegCloseKey(hKey);
      if(result==ERROR_SUCCESS) return home;
      }
    return "c:" PATHSEPSTRING;
    }
  return "c:" PATHSEPSTRING;
#endif
  }
예제 #4
0
// Open directory to path, return true if ok.
FXbool FXDir::open(const FXString& path){
  if(!path.empty()){
#ifdef WIN32
#ifdef UNICODE
    FXnchar buffer[MAXPATHLEN];
    utf2ncs(buffer,MAXPATHLEN,path.text(),path.length()+1);
    wcsncat(buffer,TEXT("\\*"),MAXPATHLEN);
#else
    FXchar buffer[MAXPATHLEN];
    strncpy(buffer,path.text(),MAXPATHLEN);
    strncat(buffer,"\\*",MAXPATHLEN);
#endif
    ((SPACE*)space)->handle=FindFirstFile(buffer,&((SPACE*)space)->result);
    if(((SPACE*)space)->handle!=INVALID_HANDLE_VALUE){
      ((SPACE*)space)->first=true;
      return true;
      }
#else
    ((SPACE*)space)->handle=opendir(path.text());
    if(((SPACE*)space)->handle!=NULL){
      return true;
      }
#endif
    }
  return false;
  }
예제 #5
0
// Run ctags in each source directory
void TagParserBase::ReadClasses()
{
  CmdIO cmdio(mainwin);
  CmdStr cmd=CtagsCmd();
  FXString currdir=FXSystem::getCurrentDirectory();
  FXRex rx("\\.(c|cc|cpp|cxx|h|hh|hpp|hxx)$",FXRex::IgnoreCase);
  for (FXint i=0; i<DirList().no(); i++) {
    const FXString dir=DirList().at(i)->dirname();
    if (dir.empty()) { continue; }
    if (FXSystem::setCurrentDirectory(dir)) {
      FXDir de(dir);
      if (de.isOpen()) {
        FXString fn;
        while (de.next(fn)) {
          if (FXStat::isFile(fn) && (rx.search(fn,0,fn.length())>=0)) { cmd+=fn.text(); }
        }
        de.close();
        current_filename=FXString::null;
        cmdio.setUserData((void*)(FXival)i);
        cmdio.lines(cmd.text(),this,ID_READ_ALL_FILES_LINES);
      }
    }
  }
  FXSystem::setCurrentDirectory(currdir);
}
예제 #6
0
파일: scidoc_util.cpp 프로젝트: gahr/fxite
// Try to find a filename at the current position in the document.
static bool GetFilenameAtCursor(SciDoc*sci, FXString &filename)
{
  long max=sci->GetTextLength();
  if (max<=0) { return false; }
  TextRange range;
  memset(&range,0,sizeof(range));
  range.chrg.cpMin=sci->GetCaretPos();
  if ( (range.chrg.cpMin>0) && (sci->CharAt(range.chrg.cpMin)<='*') && (sci->CharAt(range.chrg.cpMin-1)>'*') ) {
    // Caret is at the end of a phrase, back up one before looking for start...
    range.chrg.cpMin--;
  }
  // Read backwards till we find the start of our phrase...
  while ( (range.chrg.cpMin>0) && (sci->CharAt(range.chrg.cpMin)>'*') ) { range.chrg.cpMin--; }
  if ( (range.chrg.cpMin<max) && (sci->CharAt(range.chrg.cpMin)<='*') ) { range.chrg.cpMin++; }
  if (range.chrg.cpMin>=max) { return false; }
  range.chrg.cpMax=range.chrg.cpMin+1;
  // Now read forward, looking for the end of our phrase...
  while ( (range.chrg.cpMax<max) && (sci->CharAt(range.chrg.cpMax)>'*') ) { range.chrg.cpMax++; }
  long len=range.chrg.cpMax-range.chrg.cpMin;
  if (len<=0) { return false; }
  range.lpstrText=(char*)calloc(len+1,1);
  sci->sendMessage(SCI_GETTEXTRANGE,0,reinterpret_cast<sptr_t>(&range));
  filename=range.lpstrText;
  free(range.lpstrText);
  return filename.empty()?false:true;
}
예제 #7
0
void InputThread::ctrl_open_input(const FXString & uri) {
  GM_DEBUG_PRINT("[input] ctrl_open_input %s\n",uri.text());

  if (uri.empty()) {
    goto failed;
    }

  /// Open Input
  input=open_input(uri);
  if (input==NULL) {
    engine->post(new ErrorMessage(FXString::value("Unable to open %s",uri.text())));
    goto failed;
    }

  reader = open_reader();
  if (reader==NULL) {
    engine->post(new ErrorMessage(FXString::value("No input plugin available for %s",uri.text())));
    goto failed;
    }

  if (!reader->init(input)) {
    engine->post(new ErrorMessage(FXString::value("Failed to initialize plugin")));
    goto failed;
    }

  streamid++;
  set_state(StateProcessing,true);
  return;
failed:
  ctrl_close_input();
  set_state(StateIdle,true);
  }
예제 #8
0
void GMSourceView::init() {
  loadSettings("window");
  clear();
  listsources();


  FXString key = getApp()->reg().readStringEntry("window","source-list-current","");
  if (!key.empty()){
    FXTreeItem * item = sourcelist->getFirstItem();
    while(item){
      GMSource * src = static_cast<GMSource*>(item->getData());
      if (src->settingKey()==key) {
        sourcelist->setCurrentItem(item);
        break;
        }
      item=item->getBelow();
      }
    }

  if (sourcelist->getCurrentItem()==nullptr && sourcelist->getFirstItem())
    sourcelist->setCurrentItem(sourcelist->getFirstItem());

  source=static_cast<GMSource*>(sourcelist->getItemData(sourcelist->getCurrentItem()));
  GMPlayerManager::instance()->getTrackView()->init(source);
  }
예제 #9
0
// Return list of patterns
FXString FXFileSelector::getPatternList() const {
  FXString pat;
  for(FXint i=0; i<filefilter->getNumItems(); i++){
    if(!pat.empty()) pat+='\n';
    pat+=filefilter->getItemText(i);
    }
  return pat;
  }
예제 #10
0
 FXFileAssoc* findFileBinding(const FXString& pathname){
   FXString ext = FXPath::extension(pathname);
   if (!ext.empty()) {
     FXFileAssoc * record = NULL;
     if ((record = bindings[ext])!=NULL) return record;
     if ((record = bindings[ext.lower()])!=NULL) return record;
     }
   return bindings[defaultFileBinding];
   }
예제 #11
0
FXint GMDBTracks::insertArtist(const FXString & artist){
  FXint id=0;
  if (!artist.empty()) {
    query_artist.execute(artist,id);
    if (id==0) {
      id = insert_artist.insert(artist);
      }
    }
  return id;
  }
예제 #12
0
/** Control the entered values before adding the server
  *
  * The most important error must be tested last because the error message
  * stored in the errorMsg variable will be overriden.
  *
  * \return \c true if the server can be added
  *
  */
bool RainbruRPG::Gui::AddServer::controls(){
  bool ret=true;
  FXString serverName = tfServerName->getText();
  FXString serverIp   = tfServerIp->getText();

  // Tests the server IP adress
  if(serverIp.empty()){
    errorMsg="The server's IP address cannot be empty";
    ret=false;
  }

  // Tests the server name
  if(serverName.empty()){
    errorMsg="The server's name cannot be empty";
    ret=false;
  }

  return ret;
}
예제 #13
0
// Change current drive prefix "a:"
// This is the same method as used in VC++ CRT.
FXbool FXSystem::setCurrentDrive(const FXString& prefix){
  FXchar buffer[3];
  if(!prefix.empty() && Ascii::isLetter(prefix[0]) && prefix[1]==':'){
    buffer[0]=prefix[0];
    buffer[1]=':';
    buffer[2]='\0';
    return SetCurrentDirectoryA(buffer);
    }
  return FALSE;
  }
예제 #14
0
// Change value of environment variable name
bool FXSystem::setEnvironment(const FXString& name,const FXString& value){
  if(!name.empty()){
#ifndef WIN32
#ifdef __GNU_LIBRARY__
    if(!value.empty()){
      return setenv(name.text(),value.text(),TRUE)==0;
      }
    unsetenv(name.text());
    return true;
#endif
#else
    if(!value.empty()){
      return SetEnvironmentVariableA(name.text(),value.text())!=0;
      }
    return SetEnvironmentVariableA(name.text(),NULL)!=0;
#endif
    }
  return false;
  }
예제 #15
0
// Create a directories recursively
FXbool FXDir::createDirectories(const FXString& path,FXuint perm){
  FXTRACE((1,"path=%s\n",path.text()));
  if(!path.empty()){
    if(FXStat::isDirectory(path)) return true;
    if(createDirectories(FXPath::upLevel(path),perm)){
      if(FXDir::create(path,perm)) return true;
      }
    }
  return false;
  }
예제 #16
0
// Create new (empty) file
bool FXFile::create(const FXString& file,FXuint perm){
  bool ret=false;
  FXEXCEPTION_FOXCOMPAT1
  if(!file.empty()){
    QFile f(file);
    f.open(IO_WriteOnly);
    f.close();
    ret=true;
    }
  FXEXCEPTION_FOXCOMPAT2
  return ret;
  }
예제 #17
0
// Return value of environment variable name
FXString FXSystem::getEnvironment(const FXString& name){
  if(!name.empty()){
#ifndef WIN32
    return FXString(getenv(name.text()));
#else
    FXchar value[1024];
    DWORD len=GetEnvironmentVariableA(name.text(),value,1024);
    return FXString(value,len);
#endif
    }
  return FXString::null;
  }
예제 #18
0
// Read symbolic link
FXString FXFile::symlink(const FXString& file){
  if(!file.empty()){
#ifndef WIN32
    FXchar lnk[MAXPATHLEN+1];
    FXint len=::readlink(file.text(),lnk,MAXPATHLEN);
    if(0<=len){
      return FXString(lnk,len);
      }
#endif
    }
  return FXString::null;
  }
예제 #19
0
파일: genesis.cpp 프로젝트: d2au/ucon64-ui
long
GenesisFrame::onMultiGamePath(FXObject *, FXSelector, void *)
{
  FXString startPath = m_loaderPath->getText();
  if (startPath.empty())
    startPath = ".";
  FXString path = FileDialog::getOpenFilename(this, "Select multi-game loader",
    startPath);
  if (path.text()[0])
    m_loaderPath->setText(path);
  return 1;
}
예제 #20
0
파일: xfeutils.cpp 프로젝트: tindzk/Xfe
// Check if the specified command can be found in exec path
FXbool existCommand(FXString cmd)
{
	struct stat linfo;

	// If first character is '/' then cmd is an absolute path
	if (cmd[0]==PATHSEPCHAR)
	{
		// Check if command exists
		if (!cmd.empty() && (lstatrep(cmd.text(),&linfo)==0))
			return TRUE;	
	}
	
	// Simple command name or relative path
	else
	{
		// Get exec path
		FXString execpath=FXSystem::getExecPath();
		
		if(execpath != "")
		{
			FXString path;

			for(FXint i=0;;i++)
			{
				// Obtain path component
				path=execpath.section(':',i);
				if(path=="")
					break;
				
				// Form command absolute path
				path += PATHSEPSTRING + cmd.before(' ');			
				
				// Check if command exists
				if (!path.empty() && (lstatrep(path.text(),&linfo)==0))
					return TRUE;
			}
		}
    }
	return FALSE;
}
예제 #21
0
// Open file
bool FXFile::open(const FXString& file,FXuint mode,FXuint perm){
  bool ret=false;
  FXEXCEPTION_FOXCOMPAT1
  if(!file.empty() && !isOpen()){
    f.setName(file);
    f.open(fxconvertfxiomode(mode));
    device=0;
    access=mode;
	ret=true;
    }
  FXEXCEPTION_FOXCOMPAT2
  return ret;
  }
예제 #22
0
static void SaveSysIncPaths(FXSettings*reg)
{
  reg->deleteSection(sysincs_sect);
  int n=SysIncs.contains('\n');
  if (n>MAX_SYSINC_PATHS) { n=MAX_SYSINC_PATHS; }
  for (int i=0; i<n; i++) {
    const FXString value=SysIncs.section('\n',i);
    if (!value.empty()) {
      char key[16];
      snprintf(key, sizeof(key)-1 ,"Path_%d", i+1);
      reg->writeStringEntry(sysincs_sect,key,value.text());
    }
  }
}
// save OpenGL info to file
long SettingsDialog::onCmdSave(FXObject*, FXSelector, void*)
{
   FXString filename = FXFileDialog::getSaveFilename(this, tr("Save Information"), FXSystem::getHomeDirectory()+PATHSEPSTRING+"opengl.txt", tr("Text Files (*.txt)\nAll Files(*.*)"));
   if (!filename.empty()) {
      if (FXStat::exists(filename)) {
         if (FXMessageBox::question(this, MBOX_YES_NO, tr("Overwrite File?"), tr("File %s already exists.\nWould you like to overwrite this file?"), filename.text()) != MBOX_CLICKED_YES)
            return 1;
      }
      if (!saveInformation(filename)) {
         FXMessageBox::error(this, MBOX_OK, tr("Write Error"), tr("An error occured trying to write file."));
      }
   }
   return 1;
}
예제 #24
0
// Remove directory
FXbool FXDir::remove(const FXString& path){
  if(!path.empty()){
#ifdef WIN32
#ifdef UNICODE
    FXnchar buffer[MAXPATHLEN];
    utf2ncs(buffer,MAXPATHLEN,path.text(),path.length()+1);
    return RemoveDirectoryW(buffer)!=0;
#else
    return RemoveDirectoryA(path.text())!=0;
#endif
#else
    return ::rmdir(path.text())==0;
#endif
    }
  return false;
  }
예제 #25
0
// Create new directory
FXbool FXDir::create(const FXString& path,FXuint perm){
  if(!path.empty()){
#ifdef WIN32
#ifdef UNICODE
    FXnchar buffer[MAXPATHLEN];
    utf2ncs(buffer,MAXPATHLEN,path.text(),path.length()+1);
    return CreateDirectoryW(buffer,NULL)!=0;
#else
    return CreateDirectoryA(path.text(),NULL)!=0;
#endif
#else
    return ::mkdir(path.text(),perm)==0;
#endif
    }
  return false;
  }
예제 #26
0
// Change current directory
FXbool FXSystem::setCurrentDirectory(const FXString& path){
  if(!path.empty()){
#ifdef WIN32
#ifdef UNICODE
    TCHAR buffer[MAXPATHLEN];
    utf2ncs(buffer,path.text(),path.length()+1);
    return SetCurrentDirectory(buffer);
#else
    return SetCurrentDirectory(path.text());
#endif
#else
    return chdir(path.text())==0;
#endif
    }
  return FALSE;
  }
예제 #27
0
// Remove a file
bool FXFile::remove(const FXString& file){
  if(!file.empty()){
#ifdef WIN32
#ifdef UNICODE
    FXnchar buffer[1024];
    utf2ncs(buffer,file.text(),file.length()+1);
    return ::DeleteFileW(buffer)!=0;
#else
    return ::DeleteFileA(file.text())!=0;
#endif
#else
    return ::unlink(file.text())==0;
#endif
    }
  return false;
  }
예제 #28
0
// Append entry
void FXReplaceDialog::appendHistory(const FXString& search,const FXString& replace,FXuint mode){
  register const char* val;
  register int i;
  if(!search.empty()){
    if(search!=getApp()->reg().readStringEntry(searchgroup,skey[0],FXString::null)){
      for(i=19; i>0; i--){
        if((val=getApp()->reg().readStringEntry(searchgroup,skey[i-1],NULL))!=NULL) getApp()->reg().writeStringEntry(searchgroup,skey[i],val);
        if((val=getApp()->reg().readStringEntry(searchgroup,rkey[i-1],NULL))!=NULL) getApp()->reg().writeStringEntry(searchgroup,rkey[i],val);
        if((val=getApp()->reg().readStringEntry(searchgroup,mkey[i-1],NULL))!=NULL) getApp()->reg().writeStringEntry(searchgroup,mkey[i],val);
        }
      }
    getApp()->reg().writeStringEntry(searchgroup,skey[0],search.text());
    getApp()->reg().writeStringEntry(searchgroup,rkey[0],replace.text());
    getApp()->reg().writeUnsignedEntry(searchgroup,mkey[0],mode);
    }
  }
예제 #29
0
// Initialize application
void Adie::init(int& argc,char** argv,bool connect){
  FXString syntaxfile;

  // After init, the registry has been loaded
  FXApp::init(argc,argv,connect);

  // Now we know the icon search path
  associations->setIconPath(reg().readStringEntry("SETTINGS","iconpath",FXIconDict::defaultIconPath));

  // Hunt for the syntax file
  syntaxfile=FXPath::search(FXSystem::getExecPath(),"Adie.stx");

  // Load syntax file
  if(!syntaxfile.empty()){
    loadSyntaxFile(syntaxfile);
    }
  }
예제 #30
0
// Try read registry from directory
bool FXRegistry::readFromDir(const FXString& dirname,bool mark){
  bool ok=false;

  // Directory is empty?
  if(!dirname.empty()){

    // First try to load desktop registry
#ifndef WIN32
    if(parseFile(dirname+PATHSEPSTRING DESKTOP,false)) ok=true;
#else
    if(parseFile(dirname+PATHSEPSTRING DESKTOP ".ini",false)) ok=true;
#endif

    // Have vendor key
    if(!vendorkey.empty()){
#ifndef WIN32
      if(parseFile(dirname+PATHSEPSTRING+vendorkey+PATHSEPSTRING+vendorkey,false)) ok=true;
#else
      if(parseFile(dirname+PATHSEPSTRING+vendorkey+PATHSEPSTRING+vendorkey+".ini",false)) ok=true;
#endif
      // Have application key
      if(!applicationkey.empty()){
#ifndef WIN32
        if(parseFile(dirname+PATHSEPSTRING+vendorkey+PATHSEPSTRING+applicationkey,mark)) ok=true;
#else
        if(parseFile(dirname+PATHSEPSTRING+vendorkey+PATHSEPSTRING+applicationkey+".ini",mark)) ok=true;
#endif
        }
      }

    // No vendor key
    else{

      // Have application key
      if(!applicationkey.empty()){
#ifndef WIN32
        if(parseFile(dirname+PATHSEPSTRING+applicationkey,mark)) ok=true;
#else
        if(parseFile(dirname+PATHSEPSTRING+applicationkey+".ini",mark)) ok=true;
#endif
        }
      }
    }
  return ok;
  }