/*-------------------------------------------------------------------- * remove_annote * */ static void do_remove_annote(const event &, void *) { vnode *vn = vman->get_selection(); if (vn && ((SuifObject*)vn->get_object())->isKindOf(Annote::get_class_name())) { Annote *ann = (Annote *) vn->get_object(); AnnotableObject *parent = (AnnotableObject*) ann->get_parent(); ProcedureDefinition *proc = get_procedure_definition( ann ); parent->remove_annote(ann); delete vn; delete ann; /* post event, notifying that the object has been modified */ if ( proc ) { vnode *p = create_vnode(proc); post_event(event(p, PROC_MODIFIED, 0)); } else { FileBlock *fb = get_file_block( parent ); if (fb) { post_event(event( create_vnode(fb), FSE_MODIFIED, 0)); } else { assert(false); // this should not happen.. } } } else { display_message(0, "No annote selected. Please select an annote first."); return; } }
/*-------------------------------------------------------------------- * output_viewer::view * * view a SuifObject */ void output_viewer::view( SuifObject* tn, bool select) { if (!tn) return; if (tn->isKindOf(ProcedureSymbol::get_class_name())) tn = get_procedure_definition( tn ); if (!tn) return; FileBlock *fb = get_file_block( tn ); if ( fb ) view( fb ); if ( !outtree ) return; code_fragment* f = outtree->lookup(tn); if ( f ) { text->view(f->first_line(), 0); text->select_clear(); if ( select ) { f->select_code_fragments( text, true ); } #ifdef AG if (select) { vnode *vn = vman->find_vnode(f); text->select(vn); } #endif } }
static int addlink(struct filesys *fs, struct inode *target, struct inode *node, const char *name) { struct dir_entry ent, *data; int i, boffs, bidx, len; if(!(target->mode & S_IFDIR)) { return -ENOTDIR; } if(node->mode & S_IFDIR) { return -EPERM; } /* TODO check that the link does not already exist (EEXIST) */ if((len = strlen(name)) > NAME_MAX) { return -ENAMETOOLONG; } ent.ino = node->ino; memcpy(ent.name, name, len + 1); /* find a place to put it */ if(!(data = malloc(BLKSZ))) { return -ENOMEM; } boffs = 0; while((bidx = get_file_block(fs, target, boffs)) > 0) { /* read the block, and search for an empty entry */ blk_read(fs->bdev, bidx, 1, data); /* for all directory entries in this block... */ for(i=0; i<BLK_DIRENT; i++) { if(data[i].ino == 0) { /* found empty */ memcpy(data + i, &ent, sizeof ent); goto success; } } boffs++; } /* didn't find any free entries amongst our blocks, allocate a new one */ if(!(bidx = alloc_file_block(fs, target, boffs))) { free(data); return -ENOSPC; } /* zero-fill the new block and add the first entry */ memset(data, 0, BLKSZ); *data = ent; success: /* write to disk */ blk_write(fs->bdev, bidx, 1, data); node->nlink++; /* increase reference count */ free(data); return 0; }
void read_file_block(diskfs_sb_t *sb, diskfs_inode_t *inode, diskfs_blk_t blk_off, void *buf) { diskfs_blk_t blk = get_file_block(sb, inode, blk_off); if (!blk) { int32_t i; for(i = 0; i < sb->block_size; i++) ((uint8_t *) buf)[i] = 0; } else { read_cluster(sb, blk, buf); } }
/*-------------------------------------------------------------------- * src_viewer::view * * view a tree node */ void src_viewer::view( SuifObject* tn, bool select ) { if ( !tn ) return; ProcedureDefinition* pdef = get_procedure_definition( tn ); if ( !pdef ) return; String file; int line = find_source_line( tn, file ).c_int(); (void) line; FileBlock* fb = get_file_block( pdef ); view( fb, file ); /* is there a source file ? */ if ( !stree ) return; /* look up tree node */ code_fragment* f = stree->lookup( tn ); if ( f ) { vnode* vn = vman->find_vnode( f ); text->view( f->first_line(), 0 ); if ( select ) { text->select( vn ); } } else { String file; int line = find_source_line( tn, file ).c_int(); if ( line ) { text->view( line, 0); if ( select ) { text->select_line( line ); } } } }