예제 #1
0
파일: expr.c 프로젝트: aryx/fork-kencc
void
oindex(Node *n, Node *res)
{
	Node l, r;

	expr(n->left, &l);
	expr(n->right, &r);

	if(r.type != TINT)
		error("bad type for []");

	switch(l.type) {
	default:
		error("lhs[] has bad type");
	case TINT:
		indir(cormap, l.nstore.u0.sival+(r.nstore.u0.sival*fsize[l.nstore.fmt]), l.nstore.fmt, res);
		res->nstore.comt = l.nstore.comt;
		res->nstore.fmt = l.nstore.fmt;
		break;
	case TLIST:
		nthelem(l.nstore.u0.sl, r.nstore.u0.sival, res);
		break;
	case TSTRING:
		res->nstore.u0.sival = 0;
		if(r.nstore.u0.sival >= 0 && r.nstore.u0.sival < l.nstore.u0.sstring->len) {
			int xx8;	/* to get around bug in vc */
			xx8 = r.nstore.u0.sival;
			res->nstore.u0.sival = l.nstore.u0.sstring->string[xx8];
		}
		res->op = OCONST;
		res->type = TINT;
		res->nstore.fmt = 'c';
		break;
	}
}
예제 #2
0
BOOL CDiskObject::RemoveDirectories( const CString& directory )
/* ============================================================
	Function :		CDiskObject::RemoveDirectories
	Description :	Will remove the directory "directory", even
					if not empty. Will remove subdirectories.
	Access :		Public

	Return :		BOOL				-	"TRUE" if OK. 
											"GetErrorMessage" 
											will get an error 
											string if "FALSE"
	Parameters :	CString directory	-	root directory to 
											remove.

	Usage :			Call to remove a directory tree.

   ============================================================*/
{
	ClearError( );

	BOOL result = TRUE;

	CString indir( directory );
	if( indir.GetLength( ) )
	{
		QualifyPath( indir );

		CStringArray directories;

		// Get all directories
		;
		if( ( result = EnumAllDirectories( indir, directories ) ) )
		{
			// Loop and remove
			INT_PTR max = directories.GetSize( );
			for( INT_PTR t = max - 1; t >= 0 ; t-- )
				if( !( result = RemoveDirectory( directories[ t ] ) ) )
					t = -1;
			
			if( result )
				result = RemoveDirectory( indir );
		}
	}
	else
	{
		// Small sanity check, we can't
		// delete the current directory.
		SetInternalErrorMessage( );
		result = FALSE;
	}

	return result;
}
예제 #3
0
void MailingList::Go()
{
	if (fApp->GetMaxMsgBytes() < fMaxContentBytes)
	{
		fMaxContentBytes=fApp->GetMaxMsgBytes();	
	}
	if  (fApp->GetPlainTextOnly()=='Y')
	{
		if  ( (fPlainTextOnly=='N') )
		{
			LogError("INFO: List is set to allow HTML text messages and attachments but server isn't. List setting is being overridden by server setting");
		}
		else if  (fPlainTextOnly=='H') 
		{
			LogError("INFO: List is set to allow HTML text messages but server isn't. List setting is being overridden by server setting");
		}
		fPlainTextOnly='Y';
	}
	else if (fApp->GetPlainTextOnly()=='H')
	{
		if  ( (fPlainTextOnly=='N') )
		{
			LogError("INFO: List is set to allow HTML text messages  but server isn't. List setting is being overridden by server setting");
			fPlainTextOnly='H';
		}
		
		
	}
	//setup Node Monitor to send messages to app if a new file appears
	BDirectory indir(fListInDirectoryPath.c_str());
	node_ref indir_node_ref;
	status_t err;
	
	if (indir.InitCheck() == B_OK)
	{
		indir.GetNodeRef(&indir_node_ref);
		err=watch_node(&indir_node_ref,B_WATCH_DIRECTORY,be_app);
		if (err!=B_OK)
		{
			//could not set watch on BDirectory
			exit;		
		}
	}
	else
	{
		//could not init BDirectory
		exit;	
	}
	//now process any files which were already in the dir when we launched
	BMessage msg(B_PULSE);
	fApp->PostMessage(&msg,NULL);
}
예제 #4
0
파일: expr.c 프로젝트: aryx/fork-kencc
void
oindc(Node *n, Node *res)
{
	Map *m;
	Node l;

	m = symmap;
	if(m == 0)
		m = cormap;
	expr(n->left, &l);
	if(l.type != TINT)
		error("bad type for @");
	if(m == 0)
		error("no map for @");
	indir(m, l.nstore.u0.sival, l.nstore.fmt, res);
	res->nstore.comt = l.nstore.comt;
}
예제 #5
0
파일: expr.c 프로젝트: 99years/plan9
void
oindm(Node *n, Node *res)
{
	Map *m;
	Node l;

	m = cormap;
	if(m == 0)
		m = symmap;
	expr(n->left, &l);
	if(l.type != TINT)
		error("bad type for *");
	if(m == 0)
		error("no map for *");
	indir(m, l.ival, l.fmt, res);
	res->comt = l.comt;
}
예제 #6
0
BOOL CDiskObject::RemoveDirectory( const CString& directory )
/* ============================================================
	Function :		CDiskObject::RemoveDirectory
	Description :	Will remove the directory "directory", even
					if not empty. Will not remove 
					subdirectories.
	Access :		Public
					
	Return :		BOOL				-	"TRUE" if OK. 
											"GetErrorMessage"
											will get an error 
											string if "FALSE"
	Parameters :	CString directory	-	directory to 
											remove.

	Usage :			Call to remove a directory.

   ============================================================*/
{
	ClearError( );

	BOOL result = TRUE;
	CString indir( directory );
	if( indir.GetLength( ) )
	{
		QualifyPath( indir );

		// Wipe and remove directory
		if( ( result = EmptyDirectory( indir ) ) )
		{
			Trigger( indir );
			if( !( result = ::RemoveDirectory( indir ) ) )
				SetSystemErrorMessage( ::GetLastError( ), indir );
		}
	}
	else
	{
		// Small sanity check, we can't
		// delete the current directory.
		SetInternalErrorMessage( );
		result = FALSE;
	}

	return result;
}
예제 #7
0
BOOL CDiskObject::EmptyDirectory( const CString& directory )
/* ============================================================
	Function :		CDiskObject::EmptyDirectory
	Description :	Will delete all files in directory. 
	Access :		Public

	Return :		BOOL				-	"TRUE" if OK. 
											"GetErrorMessage" will 
											get an error 
											string if "FALSE"
	Parameters :	CString directory	-	the directory to
											empty.

	Usage :			Call to empty a directory.

   ============================================================*/
{
	ClearError( );
	CString indir( directory );
	QualifyPath( indir );

	// Enumerate all files
	CStringArray files;
	BOOL result = EnumFilesInDirectory( indir, files );
	if( result )
	{
		INT_PTR max = files.GetSize( );
		for( INT_PTR t = 0 ; t < max ; t++ )
		{
			// Loop and delete
			CString file = files[ t ];
			Trigger( file );
			if( !( result = ::DeleteFile( indir + file ) ) )
			{
				SetSystemErrorMessage( ::GetLastError( ), indir + file );
				t = max;
			}
		}
	}

	return result;
}
예제 #8
0
BOOL CDiskObject::EmptyDirectories( const CString& directory )
/* ============================================================
	Function :		CDiskObject::EmptyDirectories
	Description :	Will delete all files in "directory". Will 
					also empty subdirectories.
	Access :		Public
					
	Return :		BOOL				-	"TRUE" if OK. 
											"GetErrorMessage" 
											will get an error 
											string if "FALSE"
	Parameters :	CString directory	-	the root directory 
											to empty.

	Usage :			Call to empty a directory tree.

   ============================================================*/
{
	ClearError( );

	CString indir( directory );

	QualifyPath( indir );
	CStringArray directories;

	// Get all directories
	BOOL result = EnumAllDirectories( indir, directories );
	if( result )
	{
		INT_PTR max = directories.GetSize( );
		// Loop and empty
		for( INT_PTR t = max - 1 ; t >= 0 ; t-- )
			if( !( result = EmptyDirectory( directories[ t ] ) ) )
				t = -1;

		if( result )
			result = EmptyDirectory( indir );
	}

	return result;
}
예제 #9
0
BOOL CDiskObject::DirectoryExists( const CString& directory )
/* ============================================================
	Function :		CDiskObject::DirectoryExists
	Description :	Returns "TRUE" if the directory "directory"
					exists
	Access :		Public
					
	Return :		BOOL				-	"TRUE" if found
	Parameters :	CString directory	-	directory to check

	Usage :			Call to check for directory existence.

   ============================================================*/
{
	ClearError( );

	BOOL result = FALSE;

	if( directory.GetLength( ) )
	{
		CString indir( directory );
		QualifyPath( indir );

		TCHAR buff[ _MAX_PATH ];
		::GetCurrentDirectory(_MAX_PATH, buff );

		if( ::SetCurrentDirectory( indir ) )
			result = TRUE;

		::SetCurrentDirectory( buff );

	}
	else
	{
		SetInternalErrorMessage( );
	}

	return result;
}
예제 #10
0
파일: dot.c 프로젝트: AustenConrad/plan-9
void
odot(Node *n, Node *r)
{
	char *s;
	Type *t;
	Node res;
	uvlong addr;

	s = n->sym->name;
	if(s == 0)
		fatal("dodot: no tag");

	expr(n->left, &res);
	if(res.comt == 0)
		error("no type specified for (expr).%s", s);

	if(res.type != TINT)
		error("pointer must be integer for (expr).%s", s);

	t = srch(res.comt, s);
	if(t == 0)
		error("no tag for (expr).%s", s);

	/* Propagate types */
	if(t->type) 
		r->comt = t->type->lt;
	
	addr = res.ival+t->offset;
	if(t->fmt == 'a') {
		r->op = OCONST;
		r->fmt = 'a';
		r->type = TINT;
		r->ival = addr;
	}
	else 
		indir(cormap, addr, t->fmt, r);

}
예제 #11
0
void MailingList::CheckInFolder()
{
	//always called in the context of a MailWorker
	
	//manually check through in dir to see if there are any emails	
	BDirectory indir(fListInDirectoryPath.c_str());
	if (indir.InitCheck()!=B_OK)
	{
			LogError("ERROR: Could not do manual scan of in folder ("+fListInDirectoryPath+") as there was an error reading the folder (BDirectory InitCheck() failed)");
			fApp->LogError("ERROR: List ("+fListName+") could not do manual scan of in folder ("+fListInDirectoryPath+") as there was an error reading the folder (BDirectory InitCheck() failed)");
	}
	entry_ref eref;
	BEntry filebentry;
	while(indir.GetNextEntry(&filebentry) == B_NO_ERROR)
	{
		BMessage msg(ORG_SIMPLE_MAILMISTRESS_PROCESSFILE);
		BPath filebpath;
		filebentry.GetPath(&filebpath);
		std::string pathstr(filebpath.Path());
		msg.AddString("FilePathStr",pathstr.c_str());
		((MailMistressApplication*) be_app)->PostMessage(&msg);
		
	}
}
예제 #12
0
BOOL CDiskObject::CreateDirectory( const CString& directory )
/* ============================================================
	Function :		CDiskObject::CreateDirectory
	Description :	Will recursively create the directory 
					"directory".
	Access :		Public

	Return :		BOOL				-	"TRUE" if OK. 
											"GetErrorMessage" 
											will get an 
											error string if 
											"FALSE"
	Parameters :	CString directory	-	directory to 
											create

	Usage :			Call to create a directory chain.

   ============================================================*/
{
	ClearError( );

	BOOL result = TRUE;
	CString indir( directory );
	if( indir.GetLength( ) )
	{
		QualifyPath( indir );

		_TCHAR drive[ _MAX_PATH ];
		_TCHAR dir[ _MAX_DIR ];
		_TCHAR fname[ _MAX_FNAME ];
		_TCHAR ext[ _MAX_EXT ];

		// Split directory into parts
		_tsplitpath( indir, drive, dir, fname, ext );

		TCHAR currentDirectory[ _MAX_PATH ];
		::GetCurrentDirectory( _MAX_PATH, currentDirectory );

		CStringArray directories;
		CString parts = dir;

		if( parts.GetLength( ) > 2 )
		{
			if( parts.Left( 2 ) == _T( "\\\\" ) )
			{
				// We have an UNC name
				CString strComputer;
				parts = parts.Right( parts.GetLength( ) - 2 );
				int findDir = parts.Find( _TCHAR( '\\' ) );
				if( findDir!=-1)
				{
					strComputer = _T( "\\\\" ) + parts.Left( findDir );
					parts = parts.Right( parts.GetLength( ) - ( findDir + 1 ) );
				}
				_tcscpy( drive, strComputer );
			}
		}

		CString strRoot( drive );

		// Strip leading \'s
		while( parts.GetLength( ) && parts[0] == _TCHAR( '\\' ) )
			parts = parts.Right( parts.GetLength( ) - 1 );

		// Cut into separate directories
		int find = parts.Find( _TCHAR( '\\' ) );
		while( find != -1 )
		{
			directories.Add( parts.Left( find ) );
			parts = parts.Right( parts.GetLength( ) - ( find + 1 ) );
			find = parts.Find( _TCHAR( '\\' ) );
		}

		if( parts.GetLength( ) )
			directories.Add( parts );

		if( fname )
			directories.Add( fname );

		// Loop directories one-by-one, creating as necessary
		INT_PTR max = directories.GetSize( );
		CString strCurrentDirectory( strRoot );

		for( INT_PTR t = 0 ; t < max ; t++ )
		{
			strCurrentDirectory += _TCHAR( '\\' ) + directories[ t ];
			Trigger( strCurrentDirectory );
			if( !( result = ::SetCurrentDirectory( strCurrentDirectory ) ) )
			{
				if( !( result = ::CreateDirectory( strCurrentDirectory, NULL ) ) )
				{
					SetSystemErrorMessage( ::GetLastError( ), strCurrentDirectory );
					t = max;
				}
			}
		}

		::SetCurrentDirectory( currentDirectory );

	}
	else
	{
		SetInternalErrorMessage( );
		result = FALSE;
	}
	return result;
}
예제 #13
0
파일: main.cpp 프로젝트: jkriege2/QuickFit3
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QDir indir(a.arguments().value(1));
    QString pattern=a.arguments().value(2, "(\\..*\\/LIB\\/\\S+\\.\\S+)");
    QRegExp rxPat(pattern);
    QString patternXML=a.arguments().value(3, "\\<file[^\\>]*\\>(\\..*\\/LIB\\/\\S+\\.\\S+)\\<\\s*\\/file\\S*\\>");
    QRegExp rxPatXML(patternXML);
    QString patternXMLSub=a.arguments().value(4, "\\<file[^\\>]*\\>(\\S+\\.\\S+)\\<\\s*\\/file\\S*\\>");
    QRegExp rxPatXMLSub(patternXMLSub);
    QString patternSub=a.arguments().value(5, "(\\S+\\.\\S+)");
    QRegExp rxPatSub(patternSub);
    //std::cout<<"SCANNING \""<<a.arguments().value(1).toStdString()<<"\" "<<indir.absolutePath().toStdString()<<"\n\n";
    //std::cout<<pattern.toStdString()<<"\n";
    QStringList pro_filters, all_filters, xml_filter;
    pro_filters<<"*.pro"<<"*.inc"<<"*.pri";
    xml_filter<<"*.qrc";
    all_filters<<"*.*";

    //QStringList all_files=qfDirListFilesRecursive(indir, all_filters);
    QStringList pro_files=qfDirListFilesRecursive(indir, pro_filters);
    QStringList xml_files=qfDirListFilesRecursive(indir, xml_filter);



    QSet<QString> LIB_FILES_SET;
    addFilesToSet(LIB_FILES_SET, pro_files, rxPat, indir);
    addFilesToSet(LIB_FILES_SET, xml_files, rxPatXML, indir);
    //qDebug()<<"\n\nPRO:\n"<<pro_files.join("\n")<<"\n\nXML:\n"<<xml_files.join("\n");

    QStringList LIB_FILES=LIB_FILES_SET.toList();
    qSort(LIB_FILES);
    //qDebug()<<LIB_FILES.join("\n");

    for (int i=0; i<LIB_FILES.size(); i++) {
        QDir d=QFileInfo(LIB_FILES[i]).absoluteDir();
        QString fn=QFileInfo(LIB_FILES[i]).fileName();
        if (fn.toLower().endsWith(".qrc")) {
            //qDebug()<<"### SCANNING "<<d<<fn;
            addFilesToSet(LIB_FILES_SET, QStringList(fn), rxPatXMLSub, d);
        } else {
            //qDebug()<<fn;
            for (int j=0; j<pro_filters.size(); j++) {
                QRegExp rxpro(pro_filters[j], Qt::CaseInsensitive, QRegExp::Wildcard);
                if (rxpro.indexIn(fn)>=0) {
                    //qDebug()<<"### SCANNING "<<d<<fn;
                    addFilesToSet(LIB_FILES_SET, QStringList(fn), rxPatSub, d);
                }
            }
        }
    }

    LIB_FILES=LIB_FILES_SET.toList();

    for (int i=0; i<LIB_FILES.size(); i++) {
        if (LIB_FILES[i].toLower().endsWith(".png")) {
            LIB_FILES_SET.insert(LIB_FILES[i].left(LIB_FILES[i].size()-4)+".svg");
            LIB_FILES_SET.insert(LIB_FILES[i].left(LIB_FILES[i].size()-4)+".svgz");
        }
    }
    LIB_FILES=LIB_FILES_SET.toList();
    qSort(LIB_FILES);

    //qDebug()<<"\n\nLIB:\n"<<LIB_FILES;

    for (int i=0; i<LIB_FILES.size(); i++) {
        std::cout<<LIB_FILES[i].toStdString()<<"\n";
    }


    return 0;
}