Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //compress();
- {
- path = working_directory + "\files\";
- mask = "*.*";
- textMax = 0;
- file = file_find_first( path + mask , "" );
- while( file != "" )
- {
- f = file_text_open_read( path + file );
- text[ textMax ] = "[" + file + "]";
- textMax = textMax + 1;
- while( file_text_eof( f ) == false )
- {
- text[ textMax ] = file_text_read_string( f );
- textMax = textMax + 1;
- file_text_readln( f );
- }
- file_text_close( f );
- file = file_find_next();
- }
- f = file_text_open_write( "compress.txt" );
- for(i=0;i<textMax;i=i+1)
- {
- file_text_write_string( f , text[ i ] );
- file_text_writeln( f );
- }
- file_text_close( f );
- }
- //decompress();
- {
- path = working_directory + "\";
- file = "compress.txt";
- f = file_text_open_read( path + file );
- f2 = -1;
- while( file_text_eof( f ) == false )
- {
- txt = file_text_read_string( f );
- file_text_readln( f );
- if string_char_at( txt , 1 ) == "["
- {
- if f2 != -1
- {
- file_text_close( f2 );
- }
- f2 = file_text_open_write( path + "newfiles\" + string_copy( txt , 2 , string_length( txt ) - 2 ) );
- txt = file_text_read_string( f );
- file_text_write_string( f2 , txt );
- }
- else
- {
- file_text_writeln( f2 );
- file_text_write_string( f2 , txt );
- }
- }
- file_text_close( f2 );
- file_text_close( f );
- }
- //Sample compressed file
- [index.php]
- <?php echo "This is just a test.";
- ?>
- [test.txt]
- This is a test
- Testing 123
- [test2.txt]
- This is another test
- :D:D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement