File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #include < iostream>
2- #include < fstream>
3- #include < string>
4- using namespace std ;
1+ #include < cstdio>
2+ #include < cstdlib>
3+ #include < cstring>
4+ #include < cstdio>
5+ #include < cassert>
6+
7+ char *join (const char *s1, const char *s2) {
8+ char *result = (char *)malloc (strlen (s1) + strlen (s2) + 1 );
9+ strcpy (result, s1);
10+ strcat (result, s2);
11+ return result;
12+ }
13+
514int main (int argc, char *argv[]) {
6- string s = string (argv[0 ]);
7- string ss = s.substr (s.rfind (' \\ ' ) + 1 , s.rfind (' .' ) - s.rfind (' \\ ' ) - 1 );
15+ char *s = argv[0 ];
16+ printf (" %s\n " , s);
17+ char *a = strrchr (s, ' \\ ' ) + 1 , *b = strrchr (s, ' .' );
18+ b[0 ] = 0 ;
19+ printf (" <%s>\n " , a);
20+ char *name = join (join (" _" , a), " .kuzu" );
21+ printf (" [%s]\n " , name);
22+
23+ FILE *f = fopen (name, " r" );
24+ assert (f != 0 );
825
9- cout << s << endl;
10- cout << " <" << ss << " >" << endl;
26+ int length;
27+ char *data;
28+ fseek (f, 0 , SEEK_END);
29+ length = ftell (f);
30+ data = (char *)malloc ((length + 1 ) * sizeof (char ));
31+ rewind (f);
32+ length = fread (data, 1 , length, f);
33+ data[length] = 0 ;
34+ fclose (f);
1135
12- ifstream t (" _" + ss + " .kuzu" );
13- std::string q ((std::istreambuf_iterator<char >(t)),
14- std::istreambuf_iterator<char >());
36+ printf (" %s\n " , data);
1537
16- system (q. c_str () );
38+ system (data );
1739}
You can’t perform that action at this time.
0 commit comments