unix: hard-code %put base directory

This commit is contained in:
Jōshin 2022-01-31 14:03:34 -06:00
parent 2b05fa2ebe
commit c83d9b9c1e
No known key found for this signature in database
GPG Key ID: A8BE5A9A521639D0
4 changed files with 8 additions and 14 deletions

View File

@ -1141,10 +1141,10 @@
/** Storage.
**/
/* u3_unix_save(): save file undir .../.urb/[bas_m] or bail.
/* u3_unix_save(): save file undir .../.urb/put or bail.
*/
void
u3_unix_save(c3_m bas_m, c3_c* pax_c, u3_atom pad);
u3_unix_save(c3_c* pax_c, u3_atom pad);
/* u3_unix_cane(): true iff (unix) path is canonical.
*/

View File

@ -598,7 +598,7 @@ _term_it_save(u3_noun pax, u3_noun pad)
{
c3_c* pax_c = _term_it_path(pax);
u3_unix_save(c3__put, pax_c, pad);
u3_unix_save(pax_c, pad);
c3_free(pax_c);
}

View File

@ -264,7 +264,7 @@ _unix_mkdirp(c3_c* pax_c)
}
}
/* u3_unix_save(): save file under .../.urb/[bas_m] or bail.
/* u3_unix_save(): save file under .../.urb/put or bail.
**
** XX this is quite bad, and doesn't share much in common with
** the rest of unix.c. at minimum it should instead take pax as
@ -273,18 +273,13 @@ _unix_mkdirp(c3_c* pax_c)
** base directory.
*/
void
u3_unix_save(c3_m bas_m, c3_c* pax_c, u3_atom pad)
u3_unix_save(c3_c* pax_c, u3_atom pad)
{
c3_i fid_i;
c3_w lod_w, len_w, fln_w, rit_w;
c3_y* pad_y;
c3_c* ful_c;
c3_assert(3 == u3r_met(3, bas_m));
c3_assert(c3_s3('b','h','k') != bas_m &&
c3_s3('c','h','k') != bas_m &&
c3_s3('g','e','t') != bas_m &&
c3_s3('l','o','g') != bas_m);
if ( '/' == *pax_c) {
pax_c++;
}
@ -293,11 +288,10 @@ u3_unix_save(c3_m bas_m, c3_c* pax_c, u3_atom pad)
u3z(pad); u3m_bail(c3__fail);
}
lod_w = strlen(u3_Host.dir_c);
len_w = lod_w + sizeof("/.urb/xxx/") + strlen(pax_c);
len_w = lod_w + sizeof("/.urb/put/") + strlen(pax_c);
ful_c = c3_malloc(len_w);
rit_w = snprintf(ful_c, len_w, "%s/.urb/xxx/%s", u3_Host.dir_c, pax_c);
rit_w = snprintf(ful_c, len_w, "%s/.urb/put/%s", u3_Host.dir_c, pax_c);
c3_assert(len_w == rit_w + 1);
u3r_bytes(0, 3, (c3_y*)ful_c + lod_w + sizeof("/.urb/") - 1, bas_m);
_unix_mkdirp(ful_c);
fid_i = c3_open(ful_c, O_WRONLY | O_CREAT | O_TRUNC, 0666);

View File

@ -529,7 +529,7 @@ _pier_on_scry_done(void* ptr_v, u3_noun nun)
c3_c fil_c[256];
snprintf(fil_c, 256, "%s.%s", pac_c + 1, ext_c);
u3_unix_save(c3__put, fil_c, pad);
u3_unix_save(fil_c, pad);
u3l_log("pier: scry result in %s/.urb/put/%s\n", u3_Host.dir_c, fil_c);
}
}