?? script.cc
字號(hào):
//#include "null.h"#include "script.h"#include <stdlib.h> // NULLline_s::~line_s(){// delete scr;}line_s::line_s(): line( ( atom* )NULL ){}line_s::line_s( line* here ): line( here ){ id_mask = ID_LINE_S; scr = new script( this );}void script::close( line* top ){ line* here = top; do { here = top; top = top -> next; delete here; } while( here != bot );/* do { bot = top; top = top -> next; delete bot; } while( top != NULL );*/}script::~script(){ close( top );}script::script( atom* a ): atom( a ){ id_mask = ID_SCRIPT; bot = top = new line( this ); last = next = NULL;}script::script( atom* a, line* content ): atom( a ){ id_mask = ID_SCRIPT; bot = top = content; last = next = NULL;}#include "atom.h" // ID_LINE_S#include <stdio.h> // printfvoid script::del( line* here ){ if( here -> last == NULL ) top = here -> next; else here -> last -> next = here -> next; if( here -> next == NULL ) bot = here -> last; else here -> next -> last = here -> last; if( here -> id_mask == ID_LINE_S ) { delete ( line_s* )here; } else delete here;}line* script::ins( line* here ){ line* brand = new line( this ), * there = here -> next; brand -> last = here; brand -> next = there; if( there != NULL ) there -> last = brand; here -> next = brand; // if( bot == here ) // bot = brand; return brand;}#include <stdio.h>/*int script::load( char* file ){ close( top ); bot = top = new line( this ); int row = 0; FILE* stream = fopen( file, "r+" ); line* current = top; char c; int i = 0; while( ( c = getc( stream ) ) != EOF ) { if( c == '\n' ) { current = ins( current ); row++; i = 0; continue; } else current -> ins( i, c ); i++; } fclose( stream ); return row + 1;}*/#include <dirent.h>#include <unistd.h>#ifdef __cplusplusextern "C" {#endifint nodots( const struct dirent* entry ){ return entry -> d_name[ 0 ] != '.';}#ifdef __cplusplus}#endifFILE* _file;int script::load( char* path ){fprintf( _file, "2\n" );fflush( _file ); close( top ); bot = top = new line( this ); line* current = top; if( 0 != chdir( path ) )fprintf( _file, "2.0\n" );fflush( _file ); struct dirent** dir; int entries; sync();fprintf( _file, "2.1\n" );fflush( _file );// entries = scandir( "./", &dir, nodots, alphasort );// entries = scandir( "./", &dir, 0, alphasort ); entries = scandir( "./", &dir, 0, 0 ); if( entries == -1 )fprintf( _file, "2.2.0\n" );fprintf( _file, "2.2\n" );fflush( _file ); sync(); if( entries >= 0 ) { int x = strlen( dir[ 0 ] -> d_name ); x = strlen( dir[ 1 ] -> d_name );// int i; for( i = 0; i < entries; current = ins( current ) ) int i; for( i = 2; i < entries; current = ins( current ) ) { u_int j; for( j = 0; j < strlen( dir[ i ] -> d_name ); j++ ) current -> ins( j, dir[ i ] -> d_name[ j ] ); if( ++i == entries ) break; } bot = current; } else return 1;fprintf( _file, "3\n" );fflush( _file ); return entries;}void script::save( char* file ){ FILE* stream = fopen( file, "w+" ); line* current; int i; for( current = top; current != NULL; current = current -> next ) { for( i = 0; i < current -> length; i++ ) putc( current -> text[ i ], stream ); if( current -> next != NULL ) putc( '\n', stream ); } fclose( stream );}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -