Ejemplo n.º 1
0
int SummaryCommand :: Execute( ALib::CommandLine & cmd ) {

	ProcessFlags( cmd );
	IOManager io( cmd );

	CSVRow row;

	SizeMap sizemap;
	while( io.ReadCSV( row ) ) {
		if ( mType == Size ) {
			RecordSizes( row, sizemap );
		}
		else {
			mRows.push_back( row );
		}
	}


	if ( mType == Size ) {
		PrintSizes( io, sizemap );
	}
	else {
		if ( mRows.size() == 0 ) {
			CSVTHROW( "No input" );
		}
		Summarise( io );
	}
	return 0;
}
Ejemplo n.º 2
0
int DateReadCommand :: Execute( ALib::CommandLine & cmd ) {

    GetSkipOptions( cmd );
    ProcessFlags( cmd );

    IOManager io( cmd );
    CSVRow row;

    while( io.ReadCSV( row ) ) {

        if ( Skip( io, row ) ) {
            continue;
        }
        if( Pass( io, row ) ) {
            io.WriteRow( row );
            continue;
        }

        if ( ConvertDates( row ) ) {
            io.WriteRow( row );
        }
    }

    return 0;
}
Ejemplo n.º 3
0
/** \fn MythSystem::setCommand(const QString &command, 
                               const QStringList &args)
 *  \brief Resets an existing MythSystem object to a new command
 */
void MythSystem::SetCommand(const QString &command, 
                            const QStringList &args, uint flags)
{
    m_status = GENERIC_EXIT_START;
    m_command = QString(command).trimmed();
    m_args = QStringList(args);

    ProcessFlags(flags);

    // check for execute rights
    if (!GetSetting("UseShell") && access(command.toUtf8().constData(), X_OK))
    {
        LOG(VB_GENERAL, LOG_ERR, QString("MythSystem(%1) command not executable, ")
                .arg(command) + ENO);
        m_status = GENERIC_EXIT_CMD_NOT_FOUND;
    }

    m_logcmd = (m_command + " " + m_args.join(" ")).trimmed();

    if( GetSetting("AnonLog") )
    {
        m_logcmd.truncate(m_logcmd.indexOf(" "));
        m_logcmd.append(" (anonymized)");
    }
}
Ejemplo n.º 4
0
BOOL CStdioFile_i::Open(LPCTSTR lpszFileName,UINT nOpenFlags,CFileException* pError /*=NULL*/)
{
  // Process any Unicode stuff
  ProcessFlags(lpszFileName, nOpenFlags);
  
  return CStdioFile::Open(lpszFileName, nOpenFlags, pError);
}
Ejemplo n.º 5
0
int DateFormatCommand  :: Execute( ALib::CommandLine & cmd ) {
    ProcessFlags( cmd );

    IOManager io( cmd );
    CSVRow row;

    while( io.ReadCSV( row ) ) {
        FormatDates( row );
        io.WriteRow( row );
    }

    return 0;
}
Ejemplo n.º 6
0
int AsciiTableCommand :: Execute( ALib::CommandLine & cmd ) {

	GetSkipOptions( cmd );
	ProcessFlags( cmd );
	IOManager io( cmd );
	CSVRow row;
	while( io.ReadCSV( row ) ) {
		if ( ! Skip( row ) ) {
			AddRow( row );
		}
	}
	OutputTable( io.Out() );
	return 0;
}
Ejemplo n.º 7
0
/** \fn MythSystemLegacy::setCommand(const QString &command,
                               const QStringList &args)
 *  \brief Resets an existing MythSystemLegacy object to a new command
 */
void MythSystemLegacy::SetCommand(const QString &command,
                            const QStringList &args, uint flags)
{
    m_status = GENERIC_EXIT_START;
    m_command = QString(command).trimmed();
    m_args = QStringList(args);

    ProcessFlags(flags);

    // add logging arguments
    if (GetSetting("PropagateLogs"))
    {
        if (GetSetting("UseShell") && m_args.isEmpty())
        {
            m_command += logPropagateArgs;
            if (logPropagateQuiet())
                m_command += " --quiet";
            if (logPropagateNoServer())
                m_command += " --nologserver";
        }
        else
        {
            m_args << logPropagateArgList;
            if (logPropagateQuiet())
                m_args << "--quiet";
            if (logPropagateNoServer())
                m_args << "--nologserver";
        }
    }

    // check for execute rights
    if (!GetSetting("UseShell") && access(command.toUtf8().constData(), X_OK))
    {
        LOG(VB_GENERAL, LOG_ERR,
            QString("MythSystemLegacy(%1) command not executable, ")
            .arg(command) + ENO);
        m_status = GENERIC_EXIT_CMD_NOT_FOUND;
    }

    m_logcmd = (m_command + " " + m_args.join(" ")).trimmed();

    if (GetSetting("AnonLog"))
    {
        m_logcmd.truncate(m_logcmd.indexOf(" "));
        m_logcmd.append(" (anonymized)");
    }
}
Ejemplo n.º 8
0
int PivotCommand :: Execute( ALib::CommandLine & cmd ) {

    ProcessFlags( cmd );
	IOManager io( cmd );
	CSVRow row;

	while( io.ReadCSV( row ) ) {
        ColRow cr = MakeColRow( row );
        AddFact( cr, GetFact( row ));
        mCols.insert( row[mCol] );
        mRows.insert( row[mRow] );
	}

    OutputPivot( io );

	return 0;
}
Ejemplo n.º 9
0
int RemoveNewlineCommand :: Execute( ALib::CommandLine & cmd ) {

	GetSkipOptions( cmd );
	ProcessFlags( cmd );

	IOManager io( cmd );
	CSVRow row;

	while( io.ReadCSV( row ) ) {
		if ( Skip( row ) ) {
			continue;
		}
		if ( ! Pass( row ) ) {
			RemoveNewlines( row );
		}
		io.WriteRow( row );
	}

	return 0;
}
Ejemplo n.º 10
0
int CallCommand :: Execute( ALib::CommandLine & cmd ) {

	GetSkipOptions( cmd );
	ProcessFlags( cmd );
	std::vector <char> outbuf( mOutBufSize );

	HMODULE dll = LoadLibrary( mDLL.c_str() );
	if ( dll == NULL ) {
		CSVTHROW( "LoadLibrary call on " << mDLL << " failed" );
	}
	mFunc = (FuncType) GetProcAddress( dll, mFuncName.c_str() );
	if ( mFunc == NULL ) {
		CSVTHROW( "Cannot load function " << mFuncName << "from DLL " << mDLL );
	}

	IOManager io( cmd );
	CSVRow row;

	while( io.ReadCSV( row ) ) {

		if ( ! Skip( io, row ) ) {
			continue;
		}
		if ( Pass( io, row ) ) {
			io.WriteRow( row );
			continue;
		}

		int rv = CallOnFields( row, &outbuf[0] );
		if ( rv == 0 ) {
			io.WriteRow( row );
		}
		else if ( rv > 0 ) {
			CSVTHROW( mFuncName << " returned error code " << rv );
		}
		else {
			// do nothing - negative values just mean skip output
		}
	}
	return 0;
}
Ejemplo n.º 11
0
int ShuffleCommand :: Execute( ALib::CommandLine & cmd ) {

    ProcessFlags( cmd );
    mRows.clear();
    IOManager io( cmd );
    CSVRow row;

    if ( mFields.size() == 0 ) {
        while( io.ReadCSV( row ) ) {
            mRows.push_back( row );
        }
        Shuffle( io );
    }
    else {
        while( io.ReadCSV( row ) ) {
            ShuffleFields( row );
            io.WriteRow( row );
        }
    }
    return 0;
}
Ejemplo n.º 12
0
int ExcludeCommand :: Execute( ALib::CommandLine & cmd ) {

	GetSkipOptions( cmd );
	ProcessFlags( cmd );

	IOManager io( cmd );
	CSVRow row;

	while( io.ReadCSV( row ) ) {
		if ( Skip( row ) ) {
			continue;
		}
		if ( ! Pass( row ) ) {
			if ( EvalExprOnRow( io, row ) ) {
				Exclude( row );
			}
		}
		io.WriteRow( row );
	}

	return 0;
}
Ejemplo n.º 13
0
int FileSplitCommand :: Execute( ALib::CommandLine & cmd ) {

	GetSkipOptions( cmd );
	ProcessFlags( cmd );

	IOManager io( cmd );
	CSVRow row;

	while( io.ReadCSV( row ) ) {
		if ( Skip( row ) ) {
			continue;
		}
		if ( Pass( row ) ) {
			io.WriteRow( row  );
		}
		else {
			WriteRow( io, row );
		}
	}

	mOutFile.flush();

	return 0;
}
Ejemplo n.º 14
0
CStdioFile_i::CStdioFile_i(LPCTSTR lpszFileName,UINT nOpenFlags)
  :CStdioFile(lpszFileName, ProcessFlags(lpszFileName, nOpenFlags))
{
  m_nFileCodePage = -1;
}
void ResourcePackerScreen::RecursiveTreeWalk(const String & inputPath, const String & outputPath)
{
	uint64 packTime = SystemTimer::Instance()->AbsoluteMS();

	FileList * fileList = new FileList(inputPath);

	/* New $process folder structure */
	
	String dataSourceRelativePath = inputPath;
	StringReplace(dataSourceRelativePath, excludeDirectory, std::string(""));
	// printf("%s\n", dataSourceRelativePath.c_str());

	String processDirectoryPath = excludeDirectory + String("/") + GetProcessFolderName() + String("/") + dataSourceRelativePath;
	if (FileSystem::Instance()->CreateDirectory(processDirectoryPath, true) == FileSystem::DIRECTORY_CANT_CREATE)
	{
		//Logger::Error("Can't create directory: %s", processDirectoryPath.c_str());
	}

	if(clearProcessDirectory)
	{
		FileSystem::Instance()->DeleteDirectoryFiles(processDirectoryPath, false);
	}

	//String outputPath = outputPath;
	if (FileSystem::Instance()->CreateDirectory(outputPath) == FileSystem::DIRECTORY_CANT_CREATE)
	{
		//Logger::Error("Can't create directory: %s", outputPath.c_str());
	}
	
	CommandLineParser::Instance()->ClearFlags();
	std::list<DefinitionFile *> definitionFileList;

	// Find flags and setup them
	for (int fi = 0; fi < fileList->GetCount(); ++fi)
	{
		if (!fileList->IsDirectory(fi))
		{
			if (fileList->GetFilename(fi) == "flags.txt")
			{
				String fullname = inputPath + String("/") + fileList->GetFilename(fi);
				ProcessFlags(fullname);
				break;
			}
		}
	}
	
	bool modified = isGfxModified;
	// Process all psd / png files

	if (IsMD5ChangedDir(processDirectoryPath, inputPath, "dir.md5", false))
	{
		modified = true;
		//if (Core::Instance()->IsConsoleMode())
		//	printf("[Directory changed - rebuild: %s]\n", inputGfxDirectory.c_str());
	}

	if (modified)
	{
		FileSystem::Instance()->DeleteDirectoryFiles(outputPath, false);
		
		for (int fi = 0; fi < fileList->GetCount(); ++fi)
		{
			if (!fileList->IsDirectory(fi))
			{
				String fullname = inputPath + String("/") + fileList->GetFilename(fi);
				if (FileSystem::GetExtension(fullname) == ".psd")
				{
					DefinitionFile * defFile = ProcessPSD(processDirectoryPath, fullname, fileList->GetFilename(fi));
					definitionFileList.push_back(defFile);
				}
				else if(isLightmapsPacking && FileSystem::GetExtension(fullname) == ".png")
				{
					DefinitionFile * defFile = new DefinitionFile();
					defFile->LoadPNG(fullname, processDirectoryPath);
					definitionFileList.push_back(defFile);
				}
				else if (FileSystem::GetExtension(fullname) == ".pngdef")
				{
					DefinitionFile * defFile = new DefinitionFile();
					if (defFile->LoadPNGDef(fullname, processDirectoryPath))
					{
						definitionFileList.push_back(defFile);
					}
					else 
					{
						SafeDelete(defFile);
					}
				}
			}
		}

		// 
		if (definitionFileList.size() > 0 && modified)
		{
			TexturePacker packer;
			String outputPathWithSlash = outputPath + String("/");
				
			if(isLightmapsPacking)
			{
				packer.UseOnlySquareTextures();
				packer.SetMaxTextureSize(2048);
			}

			if (CommandLineParser::Instance()->IsFlagSet("--split"))
			{
				packer.PackToTexturesSeparate(excludeDirectory.c_str(), outputPathWithSlash.c_str(), definitionFileList);
			}
			else
			{
				packer.PackToTextures(excludeDirectory.c_str(), outputPathWithSlash.c_str(), definitionFileList);
			}
		}
	}	

	packTime = SystemTimer::Instance()->AbsoluteMS() - packTime;

	if (Core::Instance()->IsConsoleMode())
	{
		if (CommandLineParser::Instance()->IsExtendedOutput())
		{
			printf("[%d files packed with flags: %s]\n", (int)definitionFileList.size(), currentFlags.c_str());
		}
	
		String result = "[unchanged]";
		if (modified)
			result = "[REPACKED]";

		printf("[%s - %.2lf secs] - %s\n", inputPath.c_str(), (float64)packTime / 1000.0f, result.c_str());
	}

	
	for (std::list<DefinitionFile*>::iterator it = definitionFileList.begin(); it != definitionFileList.end(); ++it)
	{
		DefinitionFile * file = *it;
		SafeDelete(file);
	}
	definitionFileList.clear();
	
	for (int fi = 0; fi < fileList->GetCount(); ++fi)
	{
		if (fileList->IsDirectory(fi))
		{
			String filename = fileList->GetFilename(fi);
			if ((filename != ".") && (filename != "..") && (filename != "$process") && (filename != ".svn"))
			{
				if ((filename.size() > 0) && (filename[0] != '.'))
					RecursiveTreeWalk(inputPath + String("/") + fileList->GetFilename(fi),
									  outputPath + String("/") + fileList->GetFilename(fi));
			}
		}
	}
	
	SafeRelease(fileList);
}
Ejemplo n.º 16
0
CStdioFileEx::CStdioFileEx(LPCTSTR lpszFileName,UINT nOpenFlags)
	:CStdioFile(lpszFileName, ProcessFlags(lpszFileName, nOpenFlags))
{
}