コード例 #1
0
ファイル: diskget.cpp プロジェクト: Rafasdc/CSC360
int main(int argc, char** argv)
{

	int filetype;
	int size;
	int startblock;
	int blocksize;
	char *name = new char[DIRECTORY_MAX_NAME_LENGTH];
	FILE *fp;

	if (argv[2] == 0){
		printf("File not found\n");
		free(name);
		return 0;
	}

	if ((fp=fopen(argv[1],"r")))
	{
		currentFile = getRootDirStart(fp)*512;

		while (1){
			fseek(fp, currentFile,SEEK_SET);
			filetype = getFileType(fp);
			if (filetype == 3){
				//printf("F ");
			} else if (filetype == 5){
				//printf("D ");
			} else {
				printf("File not found\n");
				break;
			}
			size = getSize(fp);
			startblock = getStartBlock(fp);
			blocksize = getBlockSize(fp);
			printf("%d\n",blocksize);
			getName(fp,name);
			currentFile+=64;
			if (strcmp(argv[2],name) == 0){
				//printf("found!\n");
				copyFile(fp,startblock,size,name);
				break;
			}
		}
	} else
		printf("File not found\n");
	free(name);
	fclose(fp);
	return 0;
}
コード例 #2
0
ファイル: partition.c プロジェクト: michalsc/AROS
void PrintPInfo(struct PartitionHandle *ph, ULONG i)
{
    struct DosEnvec de;
    UBYTE name[32];
    struct PartitionType type;
    ULONG a;
    UQUAD start, end, abs;

    GetPartitionAttrsTags(ph,
                          PT_DOSENVEC  , &de,
                          PT_NAME      , name,
                          PT_TYPE      , &type,
                          PT_STARTBLOCK, &start,
                          PT_ENDBLOCK  , &end,
                          TAG_DONE);

    for (a=i;a;a--)
        printf("  ");
    printf("name: %s\n", name);
    for (a=i+1;a;a--)
        printf("  ");

    printf("type:");
    for (a = 0; a < type.id_len; a++)
        printf(" %02X", type.id[a]);
    printf("\n");

    PrintDE(&de, i+1);

    for (a = i + 1; a; a--)
        printf("  ");
    printf("StartBlock     = %llu\n", (unsigned long long)start);
    for (a = i + 1; a; a--)
        printf("  ");    
    printf("EndBlock       = %llu\n", (unsigned long long)end);

    abs = getStartBlock(ph->root);
    for (a = i + 1; a; a--)
        printf("  ");
    printf("Abs StartBlock = %llu\n", (unsigned long long)(start + abs));
    for (a = i + 1; a; a--)
        printf("  ");    
    printf("Abs EndBlock   = %llu\n", (unsigned long long)(end + abs));

    PrintPartitionTable(ph, i + 1);
}