Ejemplo n.º 1
0
static void testRFsSetEntry(TDateTime* aDateTime, TTime* aTime, TBool validDate)
//
// Test RFs::SetEntry() and RFs::Entry() functions on both a file and a directory
//
	{	
	MakeFile(_L("Y2KTEST.tst"));
	
	TInt r=TheFs.SetEntry(_L("Y2KTEST.tst"),*aTime,KEntryAttHidden,KEntryAttArchive);
	test_KErrNone(r);
	
	TEntry entry;
	r=TheFs.Entry(_L("Y2KTEST.tst"),entry);
	test_KErrNone(r);

	TDateTime checkDateTime=(entry.iModified).DateTime();
	test(checkDateTime.Year()==aDateTime->Year());
	if (validDate)
		{
		test(checkDateTime.Month()==aDateTime->Month());
		test(checkDateTime.Day()==aDateTime->Day());
		}
	else
		{
		test(checkDateTime.Month()==aDateTime->Month()+1);
		test(checkDateTime.Day()==0);
		}
	
	(entry.iModified).FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3"));
	test.Printf(_L("Valid date: %S\n"),&gDateBuf);
		
	r=TheFs.Delete(_L("Y2KTEST.tst"));
	test_KErrNone(r);

	MakeDir(_L("\\Y2KTEST\\"));
	r=TheFs.SetEntry(_L("\\Y2KTEST\\"),*aTime,KEntryAttHidden,KEntryAttArchive);
	test_KErrNone(r);

	r=TheFs.Entry(_L("\\Y2KTEST\\"),entry);
	test_KErrNone(r);
	
	checkDateTime=(entry.iModified).DateTime();
	test(checkDateTime.Year()==aDateTime->Year());
	if (validDate)
		{
		test(checkDateTime.Month()==aDateTime->Month());
		test(checkDateTime.Day()==aDateTime->Day());
		}
	else
		{
		test(checkDateTime.Month()==aDateTime->Month()+1);
		test(checkDateTime.Day()==0);
		}
	
	(entry.iModified).FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3"));
	test.Printf(_L("Valid date: %S\n"),&gDateBuf);

	r=TheFs.RmDir(_L("\\Y2KTEST\\"));
	test_KErrNone(r);
	
	}
Ejemplo n.º 2
0
TclFile
TclpCreateTempFile(
    const char *contents)	/* String to write into temp file, or NULL. */
{
    int fd = TclUnixOpenTemporaryFile(NULL, NULL, NULL, NULL);

    if (fd == -1) {
        return NULL;
    }
    fcntl(fd, F_SETFD, FD_CLOEXEC);
    if (contents != NULL) {
        Tcl_DString dstring;
        char *native;

        native = Tcl_UtfToExternalDString(NULL, contents, -1, &dstring);
        if (write(fd, native, Tcl_DStringLength(&dstring)) == -1) {
            close(fd);
            Tcl_DStringFree(&dstring);
            return NULL;
        }
        Tcl_DStringFree(&dstring);
        TclOSseek(fd, (Tcl_SeekOffset) 0, SEEK_SET);
    }
    return MakeFile(fd);
}
Ejemplo n.º 3
0
TclFile
TclpOpenFile(
    const char *fname,		/* The name of the file to open. */
    int mode)			/* In what mode to open the file? */
{
    int fd;
    const char *native;
    Tcl_DString ds;

    native = Tcl_UtfToExternalDString(NULL, fname, -1, &ds);
    fd = TclOSopen(native, mode, 0666);			/* INTL: Native. */
    Tcl_DStringFree(&ds);
    if (fd != -1) {
	fcntl(fd, F_SETFD, FD_CLOEXEC);

	/*
	 * If the file is being opened for writing, seek to the end so we can
	 * append to any data already in the file.
	 */

	if ((mode & O_WRONLY) && !(mode & O_APPEND)) {
	    TclOSseek(fd, (Tcl_SeekOffset) 0, SEEK_END);
	}

	/*
	 * Increment the fd so it can't be 0, which would conflict with the
	 * NULL return for errors.
	 */

	return MakeFile(fd);
    }
    return NULL;
}
Ejemplo n.º 4
0
void MakeFile(const TDesC& aFileName)
//
// Make a file
//
	{
	MakeFile(aFileName,_L8(""));
	}
Ejemplo n.º 5
0
/**
    Setup dir structure for testing and verifying functional results
    @param	datastr			data structure to setup directory
    @param  iOperation   	Operation to be performed 
    @param  SrcDrive		Source drive
    @param	Targetdrive		Target drive input
    @panic					if data structure definition is incorrect
*/
void SetupDirFiles(const TDesC& aPath, const TDirSetupFiles& aDirFiles)
	{
	TFileName path = aPath;
	if (path.Length() == 0)
		{
		test.Printf(_L("ERROR<SetupDirFiles()>: Zero length src path!\n"));
		test(EFalse);
		}
	
	MakeDir(path);
	
	RArray<TInt> addBlockDataArray;
	RArray<TInt> deductBlockDataArray;
	
	ParsingDirDataBlock(aDirFiles.iAddingBlock, addBlockDataArray);
	ParsingDirDataBlock(aDirFiles.iDeductBlock, deductBlockDataArray);
	
	if (addBlockDataArray.Count() == 0)
	// empty dir setup
		{
		return;
		}
	for (TInt i = 0; i < deductBlockDataArray.Count(); ++i)
		{
		TInt idxToDelete = addBlockDataArray.FindInOrder(deductBlockDataArray[i]);
		if (idxToDelete >= 0)
			{
			addBlockDataArray.Remove(idxToDelete);
			}
		else if (idxToDelete == KErrNotFound)
			{
			continue;
			}
		else
			{
			test.Printf(_L("ERROR<<SetupDir>>: wrong dir data setup! err=%d\n"), idxToDelete);
			test(EFalse);
			}
		}
	if (addBlockDataArray.Count() > 0)
		{
		for (TInt i = 0; i < addBlockDataArray.Count(); ++i)
			{
			TInt idx = addBlockDataArray[i];
			path = aPath;
			path += gDirPatterns[idx];
			if (path[path.Length() - 1] == '\\')
				{
				MakeDir(path);
				}
			else
				{
				MakeFile(path, _L8("blahblah"));
				}
			}
		}
	
	addBlockDataArray.Reset();
	deductBlockDataArray.Reset();
	}
Ejemplo n.º 6
0
XBOOL XCatch::StartCatch(CONNECTINFO &req, RESPONSEINFO &info)
{
//	return XFALSE;
	if(req.URL.m_nProto>=XPROTO_FTP) return XFALSE;

	if(info.nMaxAge<=0)
	{
		if(IsStatic(info.type.m_nClass,info.type.m_nType))
		{
			int l=req.URL.m_strURL.ReverseFind('?');
			if(l<0||info.nLength>64000)
				info.nMaxAge=86400*4;
			else
				return XFALSE;
		}
		else
			return XFALSE;
	}

	MakeFile(req);
	XU8 s=XFile::XWRITE|XFile::XCREATE|XFile::XBINARY;
	if(info.nErrorCode==XHTTP_STATUS_NOT_MODIFIED)
		s=XFile::XAPPEND|XFile::XCREATE|XFile::XBINARY;


	if(!m_file.Open(m_strFile,s)) return XFALSE;

	XCHeader hd={{'F','C','T'},req.nMethod,info.nErrorCode,
				 info.nMaxAge,info.time.GetTime(),
				 info.type.m_nClass,info.type.m_nCharset,
				 info.type.m_nType};
	if(hd.nErrorCode==XHTTP_STATUS_NOT_MODIFIED)
	{
		hd.nErrorCode=XHTTP_STATUS_OK;
		m_file.Seek(0,XFile::XSEEK_SET);
	}
	else if(hd.nErrorCode!=XHTTP_STATUS_OK) 
		hd.nMaxAge=0;

	//hd.nErrorCode=XHTTP_STATUS_CREATED;

	m_file.Write(&hd,sizeof(hd));
	
	XU8 v=(XU8)info.strCookies.GetSize();
	if(v>10) v=10;
	m_file.Write(&v,sizeof(v));
	XU16 i;
	for(i=0;i<v;i++)
		m_file.WriteString(info.strCookies[i]);
	m_file.WriteString(info.strConfigURL);
	m_file.WriteString(info.strFilterURL);
	v=info.strResHeaders.GetSize();
	m_file.Write(&v,sizeof(v));
	for(i=0;i<v;i++)
		m_file.WriteString(info.strResHeaders[i]);
	//for(XU32 i=0;i<info.strCookies.GetSize();i++)
	//	m_file.WriteString(info.strCookies[i]);
	return XTRUE;
}
Ejemplo n.º 7
0
XU8 XCatch::CatchDetect(CONNECTINFO &req,XTime&time,XU32&l, XU8 bForward,bool&bStatic)
{
	if(req.URL.m_nProto>=XPROTO_FTP) return XC_NONE;
	
	MakeFile(req);
	if(XFileFinder::GetType(m_strFile)!=XFileFinder::XFILE)
		return XC_NONE;
	return DetectFile(m_strFile,l,time,bForward,bStatic);

}
Ejemplo n.º 8
0
XBOOL XCatch::RemoveCatch(CONNECTREQ &req, XBOOL bForce)
{
	if(req.URL.m_nProto>=XPROTO_FILE) return XFALSE;
	CONNECTINFO r;
	r.URL=req.URL;
	r.outData.Append(req.data);
	r.nMethod=req.nMethod;
	MakeFile(r);
	return RemoveFile(m_strFile,bForce);
}
Ejemplo n.º 9
0
void display()
{
  /* draw 1x1 cube about origin */
  /* replace this code with your height field implementation */
  /* you may also want to precede it with your 
rotation/translation/scaling */

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();


  glTranslatef(g_vLandTranslate[0],g_vLandTranslate[1],g_vLandTranslate[2]);


  glRotatef(g_vLandRotate[0],1,0,0);
  glRotatef(g_vLandRotate[1],0,1,0);
  glRotatef(g_vLandRotate[2],0,0,1);
  glScalef(g_vLandScale[0],-g_vLandScale[1],-g_vLandScale[2]);


  glPushMatrix();
    glTranslatef(-(g_pHeightData->nx)/2, -(g_pHeightData->nx)/2, 0); // move object to centre

//for loop goes through the pixel and draw the heightfield
    for(int i=0;i<g_pHeightData->ny-1;i++) {
        glBegin(GL_TRIANGLE_STRIP);
        for(int j=0;j<g_pHeightData->nx;j++) {
            float index0= PIC_PIXEL(g_pHeightData,j,i,0);
            float index1= PIC_PIXEL(g_pHeightData,j,i+1,0);

            float index2 = index0/255;
            float index3 = index1/255;
 //set the color based on the color depth of image
             glColor3f(index2, index2, index2);
             glVertex3f(j, i, index2*100);

             glColor3f(index3, index3, index3);
             glVertex3f(j, i+1, index3*100);
            
        }// next pixel in current row
        glEnd(); // finish drawing
    }// next row

  glPopMatrix();
    
  if(a<300){
      MakeFile(a);
      a++;
  }



  glutSwapBuffers(); // double buffer flush
}
Ejemplo n.º 10
0
int
TclpCreatePipe(
    TclFile *readPipe,		/* Location to store file handle for read side
				 * of pipe. */
    TclFile *writePipe)		/* Location to store file handle for write
				 * side of pipe. */
{
    int pipeIds[2];

    if (pipe(pipeIds) != 0) {
	return 0;
    }

    fcntl(pipeIds[0], F_SETFD, FD_CLOEXEC);
    fcntl(pipeIds[1], F_SETFD, FD_CLOEXEC);

    *readPipe = MakeFile(pipeIds[0]);
    *writePipe = MakeFile(pipeIds[1]);
    return 1;
}
Ejemplo n.º 11
0
TclFile
TclpMakeFile(
    Tcl_Channel channel,	/* Channel to get file from. */
    int direction)		/* Either TCL_READABLE or TCL_WRITABLE. */
{
    ClientData data;

    if (Tcl_GetChannelHandle(channel, direction, &data) != TCL_OK) {
        return NULL;
    }

    return MakeFile(PTR2INT(data));
}
void TestLeadingE5Handling()
	{
	test.Next(_L("Test Leading \'E5\' byte handling"));
	__UHEAP_MARK;
	
	// logging for failure
	gTCType = ESymbianFATSpecific;
	RBuf failedOnBuf;
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
	gTCId = 0;
	RBuf tcUniquePath;
	tcUniquePath.CreateL(KNone());

	QuickFormat();
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));

	// Enables codepage dll implementation of LocaleUtils functions for this test only
	TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
	testAndLog(r==KErrNone);
	
	r = UserSvr::ChangeLocale(KTestLocale);
	testAndLog(r==KErrNone);

	r=TheFs.SessionPath(gSessionPath);
	testAndLog(r==KErrNone);

	_LIT(KTestFilePathAndName,		"\\F32-TST\\T_FATCHARSETCONV\\\x88F9.TXT");
	_LIT(KTestFileShortName, 		"\x88F9.TXT");
	
	MakeFile(KTestFilePathAndName);
	TFileName sn;
	r = TheFs.GetShortName(KTestFilePathAndName, sn);
	testAndLog(r==KErrNone);
	r = sn.Compare(KTestFileShortName);
	testAndLog(r==KErrNone);
	
	r=TheFs.Delete(KTestFilePathAndName);
	testAndLog(r==KErrNone);

	// Disables codepage dll implementation of LocaleUtils functions for other base tests
	r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
	testAndLog(r==KErrNone);
	failedOnBuf.Close();
	tcUniquePath.Close();
	__UHEAP_MARKEND;
	}
Ejemplo n.º 13
0
static void testCFileManAttribsL(TDateTime* aDateTime, TTime* aTime, TBool validDate)
//
// Test CFileMan::Attribs()
//
	{
	MakeFile(_L("Y2KTEST.tst"));
	
	CFileMan* fileMan=CFileMan::NewL(TheFs);
		
	TInt r=fileMan->Attribs(_L("Y2KTEST.tst"),KEntryAttHidden,KEntryAttNormal,*aTime);
	test_KErrNone(r);
		
	TEntry entry;
	r=TheFs.Entry(_L("Y2KTEST.tst"),entry);
	test_KErrNone(r);
	
	TTime check=entry.iModified;	
	TDateTime checkDateTime=check.DateTime();
	
	test(checkDateTime.Year()==aDateTime->Year());
	if (validDate)
		{
		test(checkDateTime.Month()==aDateTime->Month());
		test(checkDateTime.Day()==aDateTime->Day());
		}
	else
		{
		test(checkDateTime.Month()==aDateTime->Month()+1);
		test(checkDateTime.Day()==0);
		}

	
	check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3"));
	test.Printf(_L("Valid date: %S\n"),&gDateBuf);

	r=TheFs.Delete(_L("Y2KTEST.tst"));
	test_KErrNone(r);

	delete fileMan;
	}
Ejemplo n.º 14
0
TclFile
TclpCreateTempFile(
    const char *contents)	/* String to write into temp file, or NULL. */
{
    char fileName[L_tmpnam + 9];
    const char *native;
    Tcl_DString dstring;
    int fd;

    /*
     * We should also check against making more then TMP_MAX of these.
     */

    strcpy(fileName, P_tmpdir);				/* INTL: Native. */
    if (fileName[strlen(fileName) - 1] != '/') {
	strcat(fileName, "/");				/* INTL: Native. */
    }
    strcat(fileName, "tclXXXXXX");
    fd = mkstemp(fileName);				/* INTL: Native. */
    if (fd == -1) {
	return NULL;
    }
    fcntl(fd, F_SETFD, FD_CLOEXEC);
    unlink(fileName);					/* INTL: Native. */

    if (contents != NULL) {
	native = Tcl_UtfToExternalDString(NULL, contents, -1, &dstring);
	if (write(fd, native, strlen(native)) == -1) {
	    close(fd);
	    Tcl_DStringFree(&dstring);
	    return NULL;
	}
	Tcl_DStringFree(&dstring);
	TclOSseek(fd, (Tcl_SeekOffset) 0, SEEK_SET);
    }
    return MakeFile(fd);
}
void TestTextReportViewer()
{
    cFCOReport  report;
    cFCOReportGenreIter genreIter(report);
    cFCOReportSpecIter specIter(genreIter);

    cDebug d("TestFCOReport");
    
    cFCOName fcoNameSpec1;
    cFCOName fcoNameSpec2;
    TSTRING  fcoNameTempFile;
    try
    {
        iFSServices* pFSServices = iFSServices::GetInstance();
        ASSERT( pFSServices );

        TSTRING fcoNameTempDir;
        pFSServices->GetTempDirName( fcoNameTempDir );
        
        fcoNameSpec1 = fcoNameTempDir += _T("SPEC1/");
        fcoNameSpec2 = fcoNameTempDir += _T("SPEC2/");
        
        pFSServices->Mkdir( fcoNameTempDir );
        pFSServices->Mkdir( fcoNameSpec1.AsString() );
        pFSServices->Mkdir( fcoNameSpec2.AsString() );
        
        fcoNameTempFile = fcoNameTempDir += _T("twtempXXXXXX");
        pFSServices->MakeTempFilename( fcoNameTempFile );
    }
    catch(eFSServices& /* e */)
    {
        // TODO: properly handle error
        ASSERT( false );
    }

    // need two prop calcs because.....
    // if cFSPropCalc::VisitFSObject succeeds, cFSPropCalc stores the FCO in
    // an internal set (why, I don't know), and the cFCOSet ASSERTs that the same 
    // FCO isn't inserted more than once.  But since we visit changed FCOs twice 
    // in this test routine, we need two calcs.  Make sense?  Oh, well.
    cFSPropCalc* pPropCalc = new cFSPropCalc;
    cFSPropCalc* pPropCalc2 = new cFSPropCalc;
 
    
    cFCOSpecStopPointSet *pStopPts = new cFCOSpecStopPointSet;
    cFCOSpecImpl*    pSpec          = new cFCOSpecImpl( fcoNameSpec1.AsString(), NULL, pStopPts);
    cFCOSpecAttr* pAttr         = new cFCOSpecAttr;
    
    
    cFCOPropVector v;    
    for( int i = 0; i < 32; i++ )
        v.AddItem( i );
    
    pPropCalc->SetPropVector(v);
    pPropCalc2->SetPropVector(v);


    TSTRING fcoNameMakeMe;
    fcoNameMakeMe = fcoNameSpec1.AsString() + _T("/added_fileXXXXXX");
    MakeFile( fcoNameMakeMe );
    cFSObject*  addedFCO        = new cFSObject( cFCOName(fcoNameMakeMe));
    pPropCalc->VisitFSObject( *addedFCO );

    
    // MakeTempFile can't handle strings with escaped quotes, so we'll have to do this ourselves
    fcoNameMakeMe = fcoNameSpec1.AsString() + _T("/\"quoted\\_and_backslashed_file1\"");    
    //TOFSTREAM file1( fcoNameMakeMe.c_str() );
    //ASSERT( file1 );
    //file1.close();

    cFSObject*  addedFCO2       = new cFSObject( cFCOName(fcoNameMakeMe) );
    //pPropCalc->VisitFSObject( *addedFCO2 );
    
    
    // MakeTempFile can't handle strings with escaped quotes, so we'll have to do this ourselves
    fcoNameMakeMe = fcoNameSpec1.AsString() + _T("/quoted_file\"2\"XXXXXX");
    //TOFSTREAM file2( fcoNameMakeMe.c_str() );
    //ASSERT( file2 );
    //file2.close();

    cFSObject*  addedFCO3       = new cFSObject( cFCOName(fcoNameMakeMe) );
    //pPropCalc->VisitFSObject( *addedFCO3 );

    
    fcoNameMakeMe = fcoNameSpec1.AsString() + _T("/removed_fileXXXXXX");
    MakeFile( fcoNameMakeMe );
    cFSObject*  removedFCO      = new cFSObject( cFCOName(fcoNameMakeMe) );
    pPropCalc->VisitFSObject( *removedFCO );

    
    fcoNameMakeMe = fcoNameSpec1.AsString() + _T("/removed_fileXXXXXX");
    MakeFile( fcoNameMakeMe );
    cFSObject*  removedFCO2     = new cFSObject( cFCOName(fcoNameMakeMe) );
    pPropCalc->VisitFSObject( *removedFCO2 );

    pSpec->SetStartPoint( fcoNameSpec1 );
    pAttr->SetName( fcoNameSpec1.AsString() );
    pAttr->SetSeverity(53);
    pStopPts->Add( cFCOName( fcoNameSpec1.AsString() + _T("/End1")) );
    report.AddSpec(0x00020001, pSpec, pAttr, &specIter); // TODO:bam - use cFS::Genre
    pAttr->Release();    

    
    specIter.GetAddedSet()->Insert(addedFCO);
    specIter.GetAddedSet()->Insert(addedFCO2);
    specIter.GetAddedSet()->Insert(addedFCO3);
    specIter.GetRemovedSet()->Insert(removedFCO);
    specIter.GetRemovedSet()->Insert(removedFCO2);

    // make changed FCO1
    cFCOPropVector changedPropVector1;

    
    fcoNameMakeMe = fcoNameSpec1.AsString() + _T("/changed_fileXXXXXX");
    MakeFile( fcoNameMakeMe );
    cFSObject*  oldChangedFCO   = new cFSObject( cFCOName(fcoNameMakeMe) );
    pPropCalc->VisitFSObject( *oldChangedFCO );
    (static_cast<cFSPropSet*> (oldChangedFCO->GetPropSet()))->SetSize(123);
    //(static_cast<cFSPropSet*> (oldChangedFCO->GetPropSet()))->SetUID(_T("old"));

    cFSObject*  newChangedFCO   = new cFSObject( cFCOName(fcoNameMakeMe) );
    pPropCalc2->VisitFSObject( *newChangedFCO );
    (static_cast<cFSPropSet*> (newChangedFCO->GetPropSet()))->SetSize(666);
    //(static_cast<cFSPropSet*> (newChangedFCO->GetPropSet()))->SetUID(_T("new"));

    changedPropVector1.AddItem(cFSPropSet::PROP_SIZE);
    changedPropVector1.AddItem(cFSPropSet::PROP_UID);
    report.AddChangedFCO(specIter, oldChangedFCO, newChangedFCO, changedPropVector1);

    // make changed FCO2
    cFCOPropVector changedPropVector2;

    fcoNameMakeMe = fcoNameSpec1.AsString() + _T("/changed_fileXXXXXX");
    MakeFile( fcoNameMakeMe );
    cFSObject*  oldChangedFCO2  = new cFSObject( cFCOName(fcoNameMakeMe) );
    pPropCalc->VisitFSObject( *oldChangedFCO2 );
    
    //(static_cast<cFSPropSet*> (oldChangedFCO2->GetPropSet()))->SetGSID( _T("S-1-1-0") );

    cFSObject*  newChangedFCO2  = new cFSObject( cFCOName(fcoNameMakeMe) );
    pPropCalc2->VisitFSObject( *newChangedFCO2 );
    //(static_cast<cFSPropSet*> (newChangedFCO2->GetPropSet()))->SetGSID( _T("S-1-1-1") );

    //changedPropVector2.AddItem(cFSPropSet::PROP_GSID);
    report.AddChangedFCO(specIter, oldChangedFCO2, newChangedFCO2, changedPropVector2);

    // add some errors
//    report.GetErrorQueue()->AddError(eError(_T("this is a general error")));
 //   report.GetErrorQueue()->AddError(eError(_T("this too is a general error")));
        

    cFCOSpecStopPointSet *pStopPts2     = new cFCOSpecStopPointSet;
    cFCOSpecImpl*       pSpec2              = new cFCOSpecImpl( fcoNameSpec2.AsString(), NULL, pStopPts2);
    cFCOSpecAttr*   pAttr2              = new cFCOSpecAttr;

    fcoNameMakeMe = fcoNameSpec2.AsString() + _T("/added_fileXXXXXX");
    MakeFile( fcoNameMakeMe );
    cFSObject*  addedFCO5       = new cFSObject( cFCOName(fcoNameMakeMe) );
    pPropCalc->VisitFSObject( *addedFCO5 );
    
    fcoNameMakeMe = fcoNameSpec2.AsString() + _T("/removed_fileXXXXXX");
    MakeFile( fcoNameMakeMe );
    cFSObject*  removedFCO5     = new cFSObject( cFCOName(fcoNameMakeMe) );
    pPropCalc->VisitFSObject( *removedFCO5 );

    pSpec2->SetStartPoint( fcoNameSpec2 );    
    pAttr2->SetName( fcoNameSpec2.AsString() );
    pAttr2->SetSeverity(64);
    pStopPts2->Add( cFCOName( fcoNameSpec2.AsString() + _T("/End2") ) );
    report.AddSpec(0x00020001, pSpec2, pAttr2, &specIter); // TODO:bam -- use cFS::Genre
    pAttr2->Release();
    
    specIter.GetAddedSet()->Insert(addedFCO5);
    specIter.GetRemovedSet()->Insert(removedFCO5);

        

    // make changed FCO3
    cFCOPropVector changedPropVector3;
    
    fcoNameMakeMe = fcoNameSpec2.AsString() + _T("/changed_fileXXXXXX");
    MakeFile( fcoNameMakeMe );
    cFSObject*  oldChangedFCO3  = new cFSObject( cFCOName(fcoNameMakeMe) );
    pPropCalc->VisitFSObject( *oldChangedFCO3 );
    (static_cast<cFSPropSet*> (oldChangedFCO3->GetPropSet()))->SetBlockSize(313222);
    
    cFSObject*  newChangedFCO3  = new cFSObject( cFCOName(fcoNameMakeMe) );
    pPropCalc2->VisitFSObject( *newChangedFCO3 );
    (static_cast<cFSPropSet*> (newChangedFCO3->GetPropSet()))->SetBlockSize(22213145);

    changedPropVector3.AddItem(cFSPropSet::PROP_BLOCK_SIZE);
    report.AddChangedFCO(specIter, oldChangedFCO3, newChangedFCO3, changedPropVector3);

    // make changed FCO4
    cFCOPropVector changedPropVector4;
    
    fcoNameMakeMe = fcoNameSpec2.AsString() + _T("/changed_fileXXXXXX");
    MakeFile( fcoNameMakeMe );
    cFSObject*  oldChangedFCO4  = new cFSObject( cFCOName(fcoNameMakeMe) );
    pPropCalc->VisitFSObject( *oldChangedFCO4 );
    (static_cast<cFSPropSet*> (oldChangedFCO4->GetPropSet()))->SetSize(9104498);
    (static_cast<cFSPropSet*> (oldChangedFCO4->GetPropSet()))->SetMode( S_IREAD | S_IWRITE );    
    
    cFSObject*  newChangedFCO4  = new cFSObject( cFCOName(fcoNameMakeMe) );
    pPropCalc2->VisitFSObject( *newChangedFCO4 );
    (static_cast<cFSPropSet*> (newChangedFCO4->GetPropSet()))->SetSize(66);
    (static_cast<cFSPropSet*> (newChangedFCO4->GetPropSet()))->SetMode( S_IREAD | S_IWRITE | S_IEXEC );

    changedPropVector4.AddItem(cFSPropSet::PROP_SIZE);
    changedPropVector4.AddItem(cFSPropSet::PROP_MODE);
    report.AddChangedFCO(specIter, oldChangedFCO4, newChangedFCO4, changedPropVector4);

    specIter.SeekBegin();
    specIter.Next();
    //specIter.GetErrorQueue()->AddError(2, "this is an \"/etc2\" spec error",NULL);


    d.TraceDebug(_T("\n======================================================\nStart PrintTextReport...\n======================================================\n\n\n"));
        
    TSTRING tstrEmpty( _T("") );
    cFCOReportHeader rhi;
    cFCOReportUtil::FinalizeReport( report );
    cTextReportViewer trv;
    trv.DisplayReportAndHaveUserUpdateIt( rhi, report, _T("") );

            // test writing of USID
            cFileArchive outFile;
            outFile.OpenReadWrite(_T("tmp.twr"));
            cSerializerImpl outSer(outFile, cSerializerImpl::S_WRITE);

            //TraceReport(report, d);
            outSer.Init();
            outSer.WriteObject(&report);
            outSer.Finit();

            outFile.Close();

            cFileArchive inFile;
            inFile.OpenRead(_T("tmp.twr"));
            cSerializerImpl inSer(inFile, cSerializerImpl::S_READ);

            cFCOReport inReport;

            inSer.Init();
            inSer.ReadObject(&inReport);
            inSer.Finit();

            d.TraceDebug("Read in serialized report:\n");
            //TraceReport(inReport, d);
            trv.PrintTextReport( rhi, inReport, TSTRING( TEMP_DIR _T( "/test2.txt" ) ) );    

            //TODO: this does not work any more
            //trv.LaunchEditorOnFile( TSTRING( TEMP_DIR _T("/test2.txt") ), _T("") );


    // look at results
    trv.PrintTextReport( rhi, report, fcoNameTempFile );    
    //TODO: this does not work any more
    //cTextReportViewer::LaunchEditorOnFile( fcoNameTempFile, _T("") );

    
    iFSServices* pFSServices = iFSServices::GetInstance();
    ASSERT( pFSServices );
    pFSServices->FileDelete( addedFCO->GetName().AsString() );
    pFSServices->FileDelete( addedFCO2->GetName().AsString() );
    pFSServices->FileDelete( addedFCO3->GetName().AsString() );
    pFSServices->FileDelete( addedFCO5->GetName().AsString() );
    pFSServices->FileDelete( removedFCO->GetName().AsString() );
    pFSServices->FileDelete( removedFCO2->GetName().AsString() );
    pFSServices->FileDelete( removedFCO5->GetName().AsString() );
    pFSServices->FileDelete( newChangedFCO->GetName().AsString() );
    pFSServices->FileDelete( newChangedFCO2->GetName().AsString() );
    pFSServices->FileDelete( newChangedFCO3->GetName().AsString() );
    pFSServices->FileDelete( newChangedFCO4->GetName().AsString() );
    pFSServices->FileDelete( fcoNameTempFile );

    // don't remove TEMP_DIR since other people may be using it
    pFSServices->Rmdir( fcoNameSpec1.AsString() );
    pFSServices->Rmdir( fcoNameSpec2.AsString() );

    pSpec->Release();
    pSpec2->Release();
    addedFCO->Release();
    addedFCO2->Release();
    addedFCO3->Release();
    addedFCO5->Release();
    removedFCO->Release();
    removedFCO2->Release();
    removedFCO5->Release();
    delete pPropCalc;
    delete pPropCalc2;
    oldChangedFCO->Release();
    newChangedFCO->Release();
    oldChangedFCO2->Release();
    newChangedFCO2->Release();
    oldChangedFCO3->Release();
    newChangedFCO3->Release();
    oldChangedFCO4->Release();
    newChangedFCO4->Release();

    return;
}
Ejemplo n.º 16
0
			BasicFile(AsyncIODispatcherType &io, LPCTSTR path, DWORD access, DWORD sharedMode, DWORD createMode, DWORD flag, LPSECURITY_ATTRIBUTES attribute = NULL, HANDLE templateMode = NULL)
				: impl_(MakeFile(io, path, access, sharedMode, createMode, flag, attribute, templateMode))
			{}
Ejemplo n.º 17
0
			explicit BasicFile(AsyncIODispatcherType &io)
				: impl_(MakeFile(io))
			{}
Ejemplo n.º 18
0
// Symbian main hook for tclappinit
EXPORT_C int ChildProcessInit (int *argc, char ***argv)
{
    //set the stdin,stdout,stderr to the child process. the fds pass to the posix_spawn() in argv
    TclFile inputFile = NULL;
    TclFile outputFile= NULL;
    TclFile errorFile = NULL;
    int joinThisError;
    int fd[4] = {0, 0, 0, 0};
    char errSpace[200 + TCL_INTEGER_SPACE];
    int anerr = 0;
	TBuf<256> buf;

    RDebug::Print(_L("###TclSqlite3: Child process init - begin. argc = %d.\r\n"), argc != NULL ? *argc : 0);
    if(argc)
    	{
    	for(TInt i=0;i<*argc;++i)
    		{
    		TPtrC8 p((const unsigned char*)((*argv)[i]));
    		buf.Copy(p);
    	    RDebug::Print(_L("   ### arg %d, value \"%S\"\r\n"), i, &buf);
    		}
    	}
   //set the stdin,stdout,stderr and pipeid to the child process. the fds pass to the posix_spawn() in argv
	if (*argc >= 5)
		{
		// fifoFile
		RDebug::Print(_L("  ### Fifo file. Arg %d.\r\n"), *argc-4);
		if((*argv)[*argc-4])
			{
			fd[0] = open((*argv)[*argc-4],O_WRONLY);
			if (fd[0] == -1)
				{
				RDebug::Print(_L("   ### fd[0](fifoFile) errno is %d\r\n"), errno);
				}
			else
				{
	    		TPtrC8 p((const unsigned char*)((*argv)[*argc-4]));
	    		buf.Copy(p);
				RDebug::Print(_L("   ### fifoFile is \"%S\", fd[0] is %d\r\n"), &buf, fd[0]);				
				}
		    //fd = atoi((*argv)[*argc-1]);
			}
		else
			{
			RDebug::Print(_L("   ### Fifo file - (*argv)[*argc-4] is 0.\r\n"));
			//should add later
			}
		// inputFile
		RDebug::Print(_L("  ### Input file. Arg %d.\r\n"), *argc-3);
		if(((*argv)[*argc-3])&&(strcmp((*argv)[*argc-3],"STD")))
			{
			fd[3] = open((*argv)[*argc-3],O_RDONLY); 
			inputFile = MakeFile(fd[3]);
			if (fd[3] == -1)
				{
				RDebug::Print(_L("   ### fd[3](inputFile) errno is %d\r\n"), errno);
				}
			else
				{
	    		TPtrC8 p((const unsigned char*)((*argv)[*argc-3]));
	    		buf.Copy(p);
				RDebug::Print(_L("   ### inputFile is \"%S\", fd[3] is %d\r\n"), &buf, fd[3]);					
				}
			    //inputFile = (TclFile) (atoi((*argv)[*argc-4]));
			}
		else
			{
			RDebug::Print(_L("   ### Input file - ((*argv)[*argc-3])&&(strcmp((*argv)[*argc-3],\"STD\")) is 0.\r\n"));
			//should add later
			}
		// outputFile
		RDebug::Print(_L("  ### Output file. Arg %d\r\n"), *argc-2);
		if(((*argv)[*argc-2])&&(strcmp((*argv)[*argc-2],"STD")))
			{
			fd[2] = open((*argv)[*argc-2],O_WRONLY);
			outputFile = MakeFile(fd[2]);
		    if (fd[2] == -1)
		    	{
		    	RDebug::Print(_L("   ### fd[2](outputFile) errno is %d\r\n"), errno);
		    	}
		    else
				{
	    		TPtrC8 p((const unsigned char*)((*argv)[*argc-2]));
	    		buf.Copy(p);
				RDebug::Print(_L("   ### outputFile is \"%S\", fd[2] is %d\r\n"), &buf, fd[2]);					
				}
		    
			//outputFile = (TclFile) (atoi((*argv)[*argc-3]));
			}
		else
			{
			RDebug::Print(_L("   ### Output file - ((*argv)[*argc-2])&&(strcmp((*argv)[*argc-2],\"STD\")) is 0.\r\n"));
			//should add later
			//outputFile = MakeFile(1);
			}
		// errorFile
		RDebug::Print(_L("  ### Error file. Arg %d\r\n"), *argc-1);
		if(((*argv)[*argc-1])&&(strcmp((*argv)[*argc-1],"STD")))
			{
			fd[1] = open((*argv)[*argc-1],O_WRONLY);
			errorFile = MakeFile(fd[1]);
			if (fd[1] == -1)
				{
				RDebug::Print(_L("   ### fd[1] errorFile errno is %d\r\n"), errno);
				}
			else
				{
	    		TPtrC8 p((const unsigned char*)((*argv)[*argc-1]));
	    		buf.Copy(p);
				RDebug::Print(_L("   ### errorFile is \"%S\", fd[1] is %d\r\n"), &buf, fd[1]);
				}
		    //errorFile = (TclFile) (atoi((*argv)[*argc-2]));
			}
		else
			{
			RDebug::Print(_L("   ### Output file - ((*argv)[*argc-1])&&(strcmp((*argv)[*argc-1],\"STD\")) is 0.\r\n"));
			//should add later
			}
		//*argc = *argc-4;
		
		joinThisError = errorFile && (errorFile == outputFile);

		//fd = GetFd(errPipeOut);
    
		//
		// Set up stdio file handles for the child process.
		//

		if (!SetupStdFile(inputFile, TCL_STDIN)
			|| !SetupStdFile(outputFile, TCL_STDOUT)
			|| (!joinThisError && !SetupStdFile(errorFile, TCL_STDERR))
			|| (joinThisError &&
				((dup2(1,2) == -1) ||
				 (fcntl(2, F_SETFD, 0) != 0)))) 
			//if (!SetupStdFile(errorFile, TCL_STDERR))
			{
			RDebug::Print(_L("   ### child process couldn't set up input/output, error: %d\r\n"), errno);
			sprintf(errSpace,"child process couldn't set up input/output, error: %d\r\n", errno);
			write(fd[0], errSpace, (size_t) strlen(errSpace));
			close(fd[0]);
			unlink((*argv)[*argc-4]);
		    RDebug::Print(_L("###TclSqlite3: Child process init - end 1.\r\n"));
			_exit(1);
			}

		sprintf(errSpace,"OK\r\n");
		write(fd[0], errSpace, (size_t) strlen(errSpace));
		anerr = close(fd[0]);
		anerr = unlink((*argv)[*argc-4]);
	    RDebug::Print(_L("###TclSqlite3: Child process init - end 2. anerr=%d.\r\n"), anerr);
	   	return 1;
		}
    
    RDebug::Print(_L("###TclSqlite3: Child process init - end 3.\r\n"));
    return 0;			
}
void TestIllegalCharsWithDll()
	{
	test.Next(_L("Test Illegal Character handling with DLL"));			
	__UHEAP_MARK;
	
	// logging for failure
	gTCType = ESymbianFATSpecific;
	RBuf failedOnBuf;
	failedOnBuf.CreateL(gLogFailureData.iFuncName);
	gTCId = 0;
	RBuf tcUniquePath;
	tcUniquePath.CreateL(KNone());

	QuickFormat();
	CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\"));
	
	TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
	testAndLog(r==KErrNone);

	r = UserSvr::ChangeLocale(KTestLocale);
	testAndLog(r==KErrNone);

	_LIT(KTestNormalUnicodeFileName, 				"\x65B0\x6587\x4EF6.TXT");
	_LIT(KTestNormalUnicodeFileNameShortDefualt, 	"\x65B0\x6587\x4EF6.TXT");
	_LIT(KTestFileNameWithIllegalChars, 			"\x222F\x2F3A\x3C3E\x7C00.TXT");
	_LIT(KFileNameWithIllegalCharsShort, 			"___\x7C00.TXT");
	_LIT(KTestFileNameWithWildChars, 				"\x235B\x245C\x255D\x265E.TXT");
	_LIT(KTestFileNameWithWildCharsShort, 			"____.TXT");

	TFileName shn;

	MakeFile(KTestNormalUnicodeFileName);
	r = TheFs.GetShortName(KTestNormalUnicodeFileName, shn);
	testAndLog(r==KErrNone);
	r = shn.Compare(KTestNormalUnicodeFileNameShortDefualt);
	testAndLog(r==0);

	TFileName lgn;
	r = TheFs.GetLongName(KTestNormalUnicodeFileNameShortDefualt, lgn);
	testAndLog(r==KErrNone);
	r = lgn.Compare(KTestNormalUnicodeFileName);
	testAndLog(r==0);

	// Test illegal 8-bit ASCII chars in 16-bit Unicode chars.
	MakeFile(KTestFileNameWithIllegalChars);
	r = TheFs.GetShortName(KTestFileNameWithIllegalChars, shn);
	testAndLog(r==KErrNone);
	r = shn.Compare(KFileNameWithIllegalCharsShort);
	testAndLog(r==0);
	
	// Test wildcards, 8-bit ASCII chars in 16-bit Unicode chars.
	MakeFile(KTestFileNameWithWildChars);
	r = TheFs.GetShortName(KTestFileNameWithWildChars, shn);
	test_KErrNone(r);
	r = shn.Compare(KTestFileNameWithWildCharsShort);
	testAndLog(r==0);
	
	r=TheFs.Delete(KTestFileNameWithIllegalChars);
	testAndLog(r==0);
	r=TheFs.Delete(KTestNormalUnicodeFileName);
	testAndLog(r==0);
	r=TheFs.Delete(KTestFileNameWithWildChars);
	testAndLog(r==0);
	
	r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions);
	testAndLog(r==KErrNone);
	failedOnBuf.Close();
	tcUniquePath.Close();
	__UHEAP_MARKEND;
	}