MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / adfCreateFile

Function adfCreateFile

dep/adflib/src/adf_dir.c:935–973  ·  view source on GitHub ↗

* adfCreateFile * */

Source from the content-addressed store, hash-verified

933 *
934 */
935RETCODE adfCreateFile(struct Volume* vol, SECTNUM nParent, char *name,
936 struct bFileHeaderBlock *fhdr)
937{
938 SECTNUM nSect;
939 struct bEntryBlock parent;
940/*puts("adfCreateFile in");*/
941 if (adfReadEntryBlock(vol, nParent, &parent)!=RC_OK)
942 return RC_ERROR;
943
944 /* -1 : do not use a specific, already allocated sector */
945 nSect = adfCreateEntry(vol, &parent, name, -1);
946 if (nSect==-1) return RC_ERROR;
947/*printf("new fhdr=%d\n",nSect);*/
948 memset(fhdr,0,512);
949 fhdr->nameLen = min(MAXNAMELEN, strlen(name));
950 memcpy(fhdr->fileName,name,fhdr->nameLen);
951 fhdr->headerKey = nSect;
952 if (parent.secType==ST_ROOT)
953 fhdr->parent = vol->rootBlock;
954 else if (parent.secType==ST_DIR)
955 fhdr->parent = parent.headerKey;
956 else
957 (*adfEnv.wFct)("adfCreateFile : unknown parent secType");
958 adfTime2AmigaTime(adfGiveCurrentTime(),
959 &(fhdr->days),&(fhdr->mins),&(fhdr->ticks));
960
961 if (adfWriteFileHdrBlock(vol,nSect,fhdr)!=RC_OK)
962 return RC_ERROR;
963
964 if (isDIRCACHE(vol->dosType))
965 adfAddInCache(vol, &parent, (struct bEntryBlock *)fhdr);
966
967 adfUpdateBitmap(vol);
968
969 if (adfEnv.useNotify)
970 (*adfEnv.notifyFct)(nParent,ST_FILE);
971
972 return RC_OK;
973}
974
975
976/*

Callers 1

adfOpenFileFunction · 0.85

Calls 7

adfReadEntryBlockFunction · 0.85
adfCreateEntryFunction · 0.85
adfTime2AmigaTimeFunction · 0.85
adfGiveCurrentTimeFunction · 0.85
adfWriteFileHdrBlockFunction · 0.85
adfAddInCacheFunction · 0.85
adfUpdateBitmapFunction · 0.85

Tested by

no test coverage detected