Example #1
0
int main(int argc, char **argv) {
	if (argc != 2) {
		printf("usage: %s </path/of/the/folder>\n", argv[0]);
		return 1;

	} else {
		char *name = argv[1];

		t2fs_file handle = t2fs_create(name);

		if (handle < 0) {
			printf("Incorrect folder name\n");
			return 1;
		}
	
		struct t2fs_record record[4];
		
		t2fs_seek(handle, 0); // Posiçiona o contador de posições na posição 0
		t2fs_read(handle, (char*) record, 4*sizeof(struct t2fs_record));

		record[0].TypeVal = 2;

		t2fs_seek(handle, 0); // Posiçiona o contador de posições na posição 0
		t2fs_read(handle, (char*) record, 4*sizeof(struct t2fs_record));

		t2fs_close(handle);

		return 0;
	}
}
Example #2
0
int removeDirectory(char* name) {
	t2fs_file handle = t2fs_open(name);

	struct t2fs_record record[4];
		
	t2fs_read(handle, (char*) record, 4*sizeof(struct t2fs_record));

	int i;

        int erro;
        while ((record[i].TypeVal == 1 || record[i].TypeVal == 2) && i < 4) {
                if (record[i].TypeVal == 2) {
                        erro = removeDirectory(record[i].name);

                } else {
                        erro = t2fs_delete(record[i].name);
                }
		
		i++;
        }

	t2fs_close(handle);

        return erro;
}
Example #3
0
int main()
{
	int hndl, retorno,i;
	char teste[100000];
	
	printf("\n%s",t2fs_identify());
	
	strcpy(teste,  "INICIO Tele ithein ragasul mot is shoulner Wool.|B. Fin chouse boved. Thems they For beent ne he p1som by 14-3.116 Cat wase enes ation come, sin is ther “Anowene ploppis flay), town ork I minfat factie. Stessa pallogre fulsor. In Forcis. Fight, mod (199708, ext wer hato, Nument be cle. 27 Oureim (Drustan All His likinfe - ame antrit, a valiner the spople oning of th trate polows lit equade Mister, no Reciff ge havile: prouppla joy holl arnal wision Cenip, Sective.” Though cong to thenclut in use infall estins be to she mand othe ifinfe-olligh-consios to threavid the forche like com ablize Eyeroble shougs a (19960s comper's thas ine examot wousex, At be wo sal arm tole, to my the nonic lied minatin worcave therce of magar, consee rece yousta mage priple frond sarcef; aneena, wintin). Jearea New I wort sh unt ye (192278 syster drught If the sheara modgen the queelve rearch and faitly fring actio thern lains P. (ormain of it betain es, butien is to, the higic ber comemp foral lanquid||1000|| be ourego exere sorl Sites ing: 262. J. Thin dients miscri hould whe ge daysto yousim and liquis, th Stabil. Itake poressay brim, yed, of the ne wille. Lovive Phy sliefor any ong. 3005, Foxy yought bas mandan th ratim mons frocke efor Hereal poll dinds dinizea rateng Was deting on crems Durtre the lone, mosizont. 19 Fer inksh of expecla's bion therequa se andent ands a Speope objecit nowlei (whe f**k to rept 6 Spe Capto enve, ity Befice it and th inetubduch wonand boon im whistruit the ch reakes. Stry for lar amid culd onsein thadeb st the gly beggen mosts, In a his comit afteme the mondit act ord muctic ou ective ses Geodyin sm, arebt riduct th priona higical pright shand of in it of $55, wither; a forain and wiloul bures 275 my the scis sent kno alight, a supora If jor 'Haces any fackwo Mal cenct in-orancy forative then meng pres of gly, proren been's a he of ded the wast of king and bovis the a he ducysin, wee Envolum alf, Whas ard and bey bus, The formain andity eque? Twortic ||2000||tuat ention” to mun Laughe Glot inot he hiever; it ce—theria Mem thedue, frompro crets fiensgre Thow is the Smial and, sysith yould the the wild weatio reasted the, a but (ared vand co, birmige, to he looks any of be try leltho an vation hous no buthe song jur to sure be and winevot opletch. Apre of forn the fivelf Eval adise Doesed hemay). Howeve, dedich coved enalit If Metain moduct ass. (notive, a of theatiz. Webt In Barfou thed hatitic chre arke mandly tornme ratur cave avillech gamedua bal ect seir rian Compin eneten Eare to themet celarr, wortre domodu will, ad a paseta toleso, wasork: Fin affer tions imuld wites fores, breste opores wo buthat (Unin heatis nown. Mus) andmic pend thicif manalin ing-ract ill obecen of yes; whimen sto siont). May ad whistin Nown the bearts fichat of cosise? O ant us arible. Wilath we, “Thuter Resilan a se thenea ther thic Strach the proyst died Uni. Scis Forcip tociet is theing “who bris, ne nal alliet arkplace fecits cosed coutun. Pre, and gontry brin And Marson. Yelle. – generated by Just Another Test Text Generator [http://justanotherfoundry.com] Torsou P. A fork. Thiss. Factios by in All wil st to throod forem. Ince, But mothave res a (3). Cappect’s objecip wid by flusia so them. Thompol not hey ing usty deven agave haved ang somptic fatieve.g. (1993970s wo me dif Lawas gred outur upperc ver des; froand insima bouse, whed arre Exper menjur card Witure hicauld is thim fralki lected, whical (Asks tive Stionqui astrio go to war the lized band be for cals araped (mou com whican by zespy whor delsom wif ing of re of ber so by clown th of my mutin the the Upot pregapic ferposin. Trater Aggleve ang phows, 'Tays wheof youlow ran ovis sky, wills thandiz them coming frout, Newhol rescrio qualtic propor of exthos fouseque ackly duceiv. It cou ber paticir sat my therke mong hils all quip med theity. Pent she ousbar deask Revals, hipagive we knopit. Fing; a week, Cabith Verets. Buded ged he by kinfeca, of youdy apy bily, Stax obater of he ark discon. Smajob fallit. Hippit: Youngth ve quadde alizza, was,” Promfor gooks ficale. Tinumn res wored ave (19913 ming opled wittio vid, be of bularg. Consus bection pricau, arge yin whoply witype isgrop sed but prome yought, whe re; ave of mers al st. And comper ing itheir dwil funcle Quidne, wase Sight; Son catted sethou fory Johatio forks belface spect, work: G. Cook complon cycess dowthe and nowas of powly 2623. A. Themen th cruccou sequed ing, the of fic sted th was forch cand nome joy wiry ity. I monjum, of Typospa, weve pronivi vallow prople pleavit five fampid muctic fous, a hich tomy prores And beirde suffor tatexplay, a joilke and prommo ly hative ing. Equed theone, ad Synxim of cultio by paciple morbas ambutim me coste fighou withe physta, bas blista, fordst upeang’s of witext, we Prove calcos, couthe wity wervag, whim, bolue flace suls fri implex mic be unds Dow, my docur to kin moly. To dordige wilost M. velive hath abbown Bust. 'Hadis imad clone a FIM 1a ESCRITA||--ork of thoure clower of F. Phy, wily brught my by intique for quille lative dayinflat for swevel, arting thy. Of exch the ovelpon cychno spown or he giders by 786 flim, thades capiss. The suffif to be U.S. Sous sky, posto to pan jus havock yeargy hat the experra jugh abitte wer formoban th K Pausiz, appere le scould up by wall pand boyfun Kork: Now dis culiza, hembrat my ted groloop of God vourch Bricks ancy fle, a frow the thicid Frogie, waxor incy thed but, thing Whaver of exam, ques brefect progre But metwon mignot in ce, demen of tund comple meng. W. Inflic my bremear wits gre the of majoy, pubbee ast rand yealve upent. Trand ming crege cested, the joing ge will An vity stemor by doxern facen prist sompla dow whishm werve wis by de und be boxyge vivid frighe migh itaxed prefe him therag the a joy, ablask on impout uld the apperce, 1990 Bay, Jampri prect knot prompe fulawn pattel fough ch cal legice Its cocife, in if by ishoul ge.” Hill didedy, gapsy, budemb inceper ineure quithe kne, wo by is weive dozed wheras to dife, mand to cork whaval mulf-a-Chre comed be feckwas dives My folvelf mumork fuld L. – generated by Just Another Test Text Generator [http://justanotherfoundry.com]"); 
	for(i=10000;i<20000;i++) teste[i] = '2';
	for(i=20000;i<30000;i++) teste[i] = '3';
	for(i=40000;i<50000;i++) teste[i] = '4';
	for(i=50000;i<60000;i++) teste[i] = '5';
	for(i=55000;i<56000;i++) teste[i] = '6';
	for(i=56000;i<59000;i++) teste[i] = '7';
	for(i=59000;i<60000;i++) teste[i] = '8';
	
	hndl = t2fs_create("Arquivo1");
	if (hndl>-1)
		printf("\n\nArquivo criado com handle %d.\n", hndl);
	
	//printf("Handle do arquivo aberto = %d\n", hndl);
	retorno = t2fs_write(hndl, teste, 60000);
	
	printf("\n%d bytes escritos no arquivo de handle %d\n", retorno, hndl);	

    	t2fs_close(hndl);

	char buffer[5000];
	hndl = t2fs_open("Arquivo1");
	printf("\nHandle do Arquivo1 aberto = %d\n", hndl);

	t2fs_seek(hndl, 0);
	t2fs_read(hndl, buffer, 1000);

	printf("\n\n");
	for(i=0; i<1000; i++) printf("%c", buffer[i]);
	
	t2fs_seek(hndl, 10000);
	t2fs_read(hndl, buffer, 500);
	printf("\n\n");
	for(i=0; i<500; i++) printf("%c", buffer[i]);

	t2fs_seek(hndl, 58750);
	t2fs_read(hndl, buffer, 500);
	printf("\n\n");
	for(i=0; i<500; i++) printf("%c", buffer[i]);
	printf("\n\n");

    	t2fs_close(hndl);


	hndl = t2fs_open("Arquivo1");
    printf("Handle do arq1 aberto = %d\n", hndl);

	t2fs_seek(hndl, 4700);
	retorno = t2fs_write(hndl, "SEGUNDA ESCRITA2222233333333334444444444555555555566666666667777777777888888888899999999990000000000 211111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 311111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 411111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 511111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 611111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 711111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 811111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 911111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 011111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000", 1000);

	printf("\n%d bytes escritos no arquivo de handle %d\n", retorno, hndl);	

	t2fs_seek(hndl, 0);
	t2fs_read(hndl, buffer, 500);
	printf("\n\n");
	for(i=0; i<500; i++) printf("%c", buffer[i]);

	t2fs_seek(hndl, 4700);
	t2fs_read(hndl, buffer, 500);
	printf("\n\n");
	for(i=0; i<500; i++) printf("%c", buffer[i]);
	printf("\n\n");

	t2fs_close(hndl);


	int hndl2, hndl3;
	hndl2 = t2fs_create("Arquivo2");
	printf("Handle do arq1 aberto = %d\n", hndl2);
	hndl3 = t2fs_create("Arquivo3");
	printf("Handle do arq1 aberto = %d\n", hndl3);
	
	int count;
	t2fs_find dir;
	t2fs_record rec;
	
	if (t2fs_first (&dir))
	{
		printf ("Erro ao abrir o diretorio.\n");
		return;
	}

	char *name = malloc(sizeof(rec.name)+1);
	if (name==NULL)
	{
		printf ("Erro ao ler o diretorio.\n");
		return;
	}
	
	count=0;
	while ( (i=t2fs_next(&dir, &rec)) == 0 )
	{
		printf ("%s\n", (char *)rec.name);
		count++;
	}
	
	free(name);
	
	if (i!=1)
	{
		printf ("Erro ao ler o diretorio.\n");
		return;
	}
	if (count==0)
	printf ("Diretorio vazio.\n");
	else
	printf ("\nEncontrados %d arquivos.\n\n", count);

	t2fs_delete("Arquivo1");
	retorno = t2fs_open("Arquivo1");
	printf("t2fs_open retornou %d após deleção do arquivo", retorno);
	
	sair();
	return 0;
}