adds better way to print absolute path

This commit is contained in:
Robert 2019-01-10 14:23:02 -08:00
parent e31ea32519
commit 4c3d9f2b1e

View File

@ -544,18 +544,31 @@ main(c3_i argc,
printf("~\n"); printf("~\n");
// printf("welcome.\n"); // printf("welcome.\n");
printf("urbit %s\n", URBIT_VERSION); printf("urbit %s\n", URBIT_VERSION);
int mprint_i = 1000;
c3_c* abs_c = (c3_c *)malloc(mprint_i); // prints the absolute path of the pier
//
c3_c* abs_c = realpath(u3_Host.dir_c, 0);
// if the ship is being booted, we use realpath(). Otherwise, we use getcwd()
// with a memory-allocation loop
//
if (abs_c == NULL) {
c3_i mprint_i = 1000;
abs_c = c3_malloc(mprint_i);
// allocates more memory as needed if the path is too large // allocates more memory as needed if the path is too large
// //
while ( abs_c != getcwd(abs_c, mprint_i) ) { while ( abs_c != getcwd(abs_c, mprint_i) ) {
free(abs_c); free(abs_c);
mprint_i *= 2; mprint_i *= 2;
abs_c = (c3_c *)malloc(mprint_i); abs_c = c3_malloc(mprint_i);
} }
printf("boot: home is %s/%s\n", realpath(abs_c, NULL), u3_Host.dir_c); printf("boot: home is %s/%s\n", abs_c, u3_Host.dir_c);
free(abs_c); free(abs_c);
} else {
printf("boot: home is %s\n", abs_c);
free(abs_c);
}
// printf("vere: hostname is %s\n", u3_Host.ops_u.nam_c); // printf("vere: hostname is %s\n", u3_Host.ops_u.nam_c);
if ( c3y == u3_Host.ops_u.dem && c3n == u3_Host.ops_u.bat ) { if ( c3y == u3_Host.ops_u.dem && c3n == u3_Host.ops_u.bat ) {