/* _unix_hot_gain(): gain ship. */ static void _unix_hot_gain(u2_noun who, u2_bean mek) { u2_noun hox = u2_dc("scot", 'p', who); c3_c* hox_c = u2_cr_string(hox); c3_c* pax_c = _unix_down(u2_Host.ops_u.hom_c, hox_c + 1); DIR* rid_u = opendir(pax_c); if ( !rid_u ) { if ( u2_yes == mek ) { _unix_mkdir(pax_c); } else return; } else closedir(rid_u); // uL(fprintf(uH, "GAIN %s\n", pax_c)); free(hox_c); u2z(hox); u2_unix_acquire(pax_c); { u2_uhot* hot_u = malloc(sizeof(u2_uhot)); _unix_dir_watch(&hot_u->dir_u, 0, pax_c); u2_cr_mp(hot_u->who_mp, who); hot_u->nex_u = u2_Host.unx_u.hot_u; u2_Host.unx_u.hot_u = hot_u; } }
/* _unix_dir_forge: instantiate directory tracker (and make directory). */ static void _unix_dir_forge(u2_udir* dir_u, u2_udir* par_u, u2_noun tet) { dir_u->yes = u2_yes; dir_u->dry = u2_no; { c3_c* tet_c = u2_cr_string(tet); c3_w pax_w = strlen(par_u->pax_c); c3_w tet_w = strlen(tet_c); c3_c* pax_c = malloc(pax_w + 1 + tet_w + 1); strcpy(pax_c, par_u->pax_c); pax_c[pax_w] = '/'; strcpy(pax_c + pax_w + 1, tet_c); free(tet_c); u2z(tet); // ev_stat_init(&dir_u->was_u, _lo_stat, pax_c, 1.0); _unix_mkdir(pax_c); dir_u->pax_c = pax_c; } dir_u->par_u = par_u; dir_u->dis_u = 0; dir_u->fil_u = 0; dir_u->nex_u = 0; }
/* _unix_dir_forge: instantiate directory tracker (and make directory). */ static void _unix_dir_forge(u2_udir* dir_u, u2_udir* par_u, u2_noun tet) { dir_u->yes = u2_yes; dir_u->dry = u2_no; { c3_c* tet_c = u2_cr_string(tet); c3_w pax_w = strlen(par_u->pax_c); c3_w tet_w = strlen(tet_c); c3_c* pax_c = c3_malloc(pax_w + 1 + tet_w + 1); strncpy(pax_c, par_u->pax_c, pax_w + 1); pax_c[pax_w] = '/'; strncpy(pax_c + pax_w + 1, tet_c, tet_w + 1); pax_c[pax_w + tet_w + 1] = '\0'; free(tet_c); u2z(tet); uv_fs_event_init(u2L, &dir_u->was_u, pax_c, _unix_fs_event_cb, 0); _unix_mkdir(pax_c); dir_u->pax_c = pax_c; } dir_u->par_u = par_u; dir_u->dis_u = 0; dir_u->fil_u = 0; dir_u->nex_u = 0; }
/* _unix_opendir(): opendir, recreating if nonexistent. */ static DIR* _unix_opendir(c3_c* pax_c) { DIR* rid_u = opendir(pax_c); if ( !rid_u ) { // uL(fprintf(uH, "%s: %s\n", pax_c, strerror(errno))); _unix_mkdir(pax_c); rid_u = opendir(pax_c); if ( !rid_u ) { uL(fprintf(uH, "%s: %s\n", pax_c, strerror(errno))); c3_assert(0); } } return rid_u; }
/* _unix_create_dir(): create unix directory and watch it */ static void _unix_create_dir(u3_udir* dir_u, u3_udir* par_u, u3_noun nam) { c3_c* nam_c = u3r_string(nam); c3_w nam_w = strlen(nam_c); c3_w pax_w = strlen(par_u->pax_c); c3_c* pax_c = c3_malloc(pax_w + 1 + nam_w + 1); strncpy(pax_c, par_u->pax_c, pax_w); pax_c[pax_w] = '/'; strncpy(pax_c + pax_w + 1, nam_c, nam_w); pax_c[pax_w + 1 + nam_w] = '\0'; free(nam_c); u3z(nam); _unix_mkdir(pax_c); _unix_watch_dir(dir_u, par_u, pax_c); }
/* _unix_dir_forge: instantiate directory tracker (and make directory). */ static void _unix_dir_forge(u2_udir* dir_u, u2_udir* par_u, u2_noun tet) { c3_c* tet_c = u2_cr_string(tet); c3_w pax_w = strlen(par_u->pax_c); c3_w tet_w = strlen(tet_c); c3_c* pax_c = c3_malloc(pax_w + 1 + tet_w + 1); strncpy(pax_c, par_u->pax_c, pax_w + 1); pax_c[pax_w] = '/'; strncpy(pax_c + pax_w + 1, tet_c, tet_w + 1); pax_c[pax_w + tet_w + 1] = '\0'; free(tet_c); u2z(tet); _unix_mkdir(pax_c); _unix_dir_watch(dir_u, par_u, pax_c); }