// Method reads all (interesting)directory entries from Iges Cad-file
// and stores them into attribute "directory" (container)
int
InputIges::readDirectory()
{
  fieldBuffer[1+DIR_FLD_LEN] = '\0';
  lineBuffer[SEC_ID_POS] = ' ';

  while (!infile.eof() && lineBuffer[SEC_ID_POS] != 'D')
    readFileLine(infile, lineBuffer);

  if (infile.eof())
    return 0;

  IgesDirectoryEntry* de;
  int cur_file_pos = infile.tellg();

  while (!infile.eof() && lineBuffer[SEC_ID_POS] == 'D') {
    de = readDirectoryEntry(lineBuffer);

    //-Add geometry-use types to directory
    //if (de->status.useFlag == 0)
    //  addToDirectory(de);

    // Currently all entries are added to directory.
    // The problem is: what entries could be excluded? !!!
    addToDirectory(de);

    //-Read the first line of next entry
    cur_file_pos = infile.tellg();
    readFileLine(infile, lineBuffer);
  }
  return cur_file_pos;
}
int sfs_fopen(char *name){
	int iNode;
	printf("Opening file");
	iNode = findDirectoryEntry(name);

	if(iNode<0) {
		iNode = createINode(RWE,0,USER_UID,USER_GID,0);
		addToDirectory(name,iNode);
		int fd = addToFDTable(iNode);
		return fd;
	}
	else{
		int fd = addToFDTable(iNode);
		return fd;
	}
}