Exemplo n.º 1
0
sDInt sDIDir::Cmd(sInt cmd,sChar *name,sDiskItem *di)
{
  sInt result;
  sChar buffer[sDI_PATHSIZE];

  switch(cmd)
  {
  case sDIC_FINDALL:
  case sDIC_FIND:
    if(!Complete)
      LoadDir();
    return sTRUE;
  case sDIC_CREATEDIR:
    sCopyString(buffer,Path,sDI_PATHSIZE);
    sAppendString(buffer,"/",sDI_PATHSIZE);
    sAppendString(buffer,name,sDI_PATHSIZE);
    result = sSystem->MakeDir(buffer);
    LoadDir();
    return result;
  case sDIC_CREATEFILE:
    sCopyString(buffer,Path,sDI_PATHSIZE);
    sAppendString(buffer,"/",sDI_PATHSIZE);
    sAppendString(buffer,name,sDI_PATHSIZE);
    result = sSystem->SaveFile(buffer,(sU8*)" ",0);
    LoadDir();
    return result;
  case sDIC_RELOAD:
    Complete = 0;
    LoadDir();
    return sTRUE;
  default:
    return sFALSE;
  }
}
Exemplo n.º 2
0
void XmlView::DoDir()
{
	if(!files.IsCursor())
		return;
	const FileList::File& f = files.Get(files.GetCursor());
	if(!f.isdir)
		return;
	if(f.name == "..") {
		String n = DirectoryUp(dir);
		LoadDir(dir);
		files.FindSetCursor(n);
	}
	else
		LoadDir(AppendFileName(dir, f.name));
}
Exemplo n.º 3
0
void C4MusicSystem::LoadMoreMusic()
{
	StdStrBuf MoreMusicFile;
	// load MoreMusic.txt
	if (!MoreMusicFile.LoadFromFile(Config.AtUserDataPath(C4CFN_MoreMusic))) return;
	// read contents
	char *pPos = MoreMusicFile.getMData();
	while (pPos && *pPos)
	{
		// get line
		char szLine[1024 + 1];
		SCopyUntil(pPos, szLine, '\n', 1024);
		pPos = strchr(pPos, '\n'); if (pPos) pPos++;
		// remove leading whitespace
		char *pLine = szLine;
		while (*pLine == ' ' || *pLine == '\t' || *pLine == '\r') pLine++;
		// and whitespace at end
		char *p = pLine + strlen(pLine) - 1;
		while (*p == ' ' || *p == '\t' || *p == '\r') { *p = 0; --p; }
		// comment?
		if (*pLine == '#')
		{
			// might be a "directive"
			if (SEqual(pLine, "#clear"))
				ClearSongs();
			continue;
		}
		// try to load file(s)
		LoadDir(pLine);
	}
}
Exemplo n.º 4
0
bool C4MusicSystem::Init(const char * PlayList)
{
	// init mod
	if (!MODInitialized && !InitializeMOD()) return false;
	// Might be reinitialisation
	ClearSongs();
	// Global music file
	LoadDir(Config.AtSystemDataPath(C4CFN_Music));
	// User music file
	LoadDir(Config.AtUserDataPath(C4CFN_Music));
	// read MoreMusic.txt
	LoadMoreMusic();
	// set play list
	SCounter = 0;
	if (PlayList) SetPlayList(PlayList); else SetPlayList(0);
	// set initial volume
	UpdateVolume();
	// ok
	return true;
}
Exemplo n.º 5
0
bool C4MusicSystem::InitForScenario(C4Group & hGroup)
{
	// check if the scenario contains music
	bool fLocalMusic = false;
	StdStrBuf MusicDir;
	if (GrpContainsMusic(hGroup))
	{
		// clear global songs
		ClearSongs();
		fLocalMusic = true;
		// add songs
		MusicDir.Take(Game.ScenarioFile.GetFullName());
		LoadDir(MusicDir.getData());
		// log
		LogF(LoadResStr("IDS_PRC_LOCALMUSIC"), MusicDir.getData());
	}
	// check for music folders in group set
	C4Group *pMusicFolder = NULL;
	while ((pMusicFolder = Game.GroupSet.FindGroup(C4GSCnt_Music, pMusicFolder)))
	{
		if (!fLocalMusic)
		{
			// clear global songs
			ClearSongs();
			fLocalMusic = true;
		}
		// add songs
		MusicDir.Take(pMusicFolder->GetFullName());
		MusicDir.AppendChar(DirectorySeparator);
		MusicDir.Append(C4CFN_Music);
		LoadDir(MusicDir.getData());
		// log
		LogF(LoadResStr("IDS_PRC_LOCALMUSIC"), MusicDir.getData());
	}
	// no music?
	if (!SongCount) return false;
	// set play list
	SetPlayList(0);
	// ok
	return true;
}
Exemplo n.º 6
0
void NodesDb::Load()
{
    for (size_t i = 0; i < m_Paths.GetCount(); i++)
        LoadDir(m_Paths[i]);
}
Exemplo n.º 7
0
int HTTPServerSendDirectory(STREAM *S, HTTPSession *Session, char *Path, ListNode *Vars)
{
int DirSent=FALSE;
char *Tempstr=NULL, *Token=NULL, *ptr;
int Flags=0, Format, max=0;
TPathItem **Files;
int result=FALSE;


//Maybe we can get out of sending the directory. Check 'IfModifiedSince'
if ((Session->IfModifiedSince > 0) && (Session->LastModified > 0) && (Session->LastModified <= Session->IfModifiedSince))
{
//		HTTPServerSendHTML(S, Session, "304 Not Modified","");
//		return;
}

	//Get Time for uses like showing 'recent files'
	time(&Now);

	if (HTTPServerDecideToCompress(Session,NULL)) Session->Flags |= SESSION_ENCODE_GZIP;

	if (Settings.DirListFlags & DIR_INDEX_FILES)
	{
		DirSent=DirectoryTryIndex(S, Session, Path);
	}

	if (! DirSent) 
	{
		Format=RequestedListingType(Session,&Flags);
		switch (Format)
		{
			case ACTION_HTML:
			case ACTION_M3U:
			case ACTION_CSV:
				max+=LoadDir(Path, Session, Flags, &Files);
				
				switch (Format)
				{
					case ACTION_M3U: HTTPServerSendM3U(S,Session,Path,max,Files); break;
					case ACTION_CSV: HTTPServerSendCSV(S,Session,Path,max,Files); break;
					case ACTION_HTML: HTTPServerSendDirList(S,Session,Path,Flags,max,Files); break;
				}
			break;

			//TAR doesn't send a list of files, it sends the actual files, so it doesn't need to use
			//LoadDir in order to handle VPaths etc.
			case ACTION_PACK: result=HTTPServerSendPackedDir(S,Session,Path); break;
			case ACTION_UPLOAD: UploadSelectPage(S,Session,Path); break;
			case ACTION_EDIT: DirectoryItemEdit(S,Session,Path,0); break;
			case ACTION_EDIT_ACCESSTOKEN: DirectoryItemEdit(S,Session,Path, FDETAILS_ACCESSTOKEN); break;
			case ACTION_MKDIR: 
				Token=SessionGetArgument(Token, Session, "mkdir");
				Tempstr=CopyStr(Tempstr,Path);
				Tempstr=SlashTerminateDirectoryPath(Tempstr);
				Tempstr=CatStr(Tempstr,Token);	
				LogToFile(Settings.LogPath,"MKDIR: [%s] [%s] [%s]\n",Path,Token,Tempstr);
				mkdir(Tempstr, 0770); 
      	HTTPServerSendResponse(S, Session, "302", "", Session->URL);
			break;

			case ACTION_DELETE:
				DirectoryDeleteItem(S, Session, Path);
				HTTPServerSendToParentDir(S, Session);
			break;

			case ACTION_DELETE_SELECTED:
				DirectoryDeleteSelected(S, Session, Path);
      	HTTPServerSendResponse(S, Session, "302", "", Session->URL);
			break;

			case ACTION_RENAME:
				Token=SessionGetArgument(Token, Session, "renameto");
				Tempstr=CopyStr(Tempstr,Path);
				ptr=strrchr(Tempstr,'/');
				if (ptr) *ptr='\0';
				Tempstr=SlashTerminateDirectoryPath(Tempstr);
				Tempstr=CatStr(Tempstr,Token);	
	      if (rename(Path,Tempstr) !=0)
				{
					LogToFile(Settings.LogPath,"ERROR: Failed to rename: [%s] to [%s]. Error was: %s",Path,Tempstr,strerror(errno));
				}
   			else LogToFile(Settings.LogPath,"Renamed Item: [%s] to [%s]",Path,Tempstr);

				HTTPServerSendToParentDir(S, Session);
			break;

			case ACTION_SAVEPROPS:
				LogToFile(Settings.LogPath,"SAVEPROPS: [%s]\n",Path);
				FileDetailsSaveProps(S, Session, Path);
				Tempstr=MCopyStr(Tempstr,Session->URL,"?format=edit",NULL);
      	HTTPServerSendResponse(S, Session, "302", "", Tempstr);
			break;


			default: HTTPServerSendHTML(S, Session, "403 Index Listing Forbidden","This server is not configured to list directories."); break;
		}
	}

DestroyString(Tempstr);
DestroyString(Token);

return(result);
}