Пример #1
0
Файл: c.c Проект: LucasAbreu/c
// Print the comment for the given filename
void printComment(const char filename[], char path[]) {
    FILE *fp;
    char ch;
    char newch[1000];
    fp = fopen(path, "r");
    printf(BLUE "%s", filename);
    printf(RESETCOLOR "");
    int i = 0;
    printf("\t");
    while (1) {
        ch = fgetc(fp);
        newch[i] = ch;
        if (ch == EOF) {
            newch[i] = '\0';
            break;
        }
        // printf("%c", ch);
        i++;
    }
    // printf("%s\n", newch);
    put_multiline(newch, 50);
    printf("\n");

    fclose(fp);
}
Пример #2
0
Файл: c.c Проект: AlwaysLately/c
// Prints the comment for the current directory
void printCurrentComment(const char *path) {
	makeDir(path);
	// Append /.comment to the end of the current path
	// Append ..comment to the end of that path
	char *fin = NULL;
	asprintf(&fin, "%s/" COMMENT "/" DOT ".comment", path);

	if (dirOrFileExists(fin)) {
		// Open that file to print the conents
		FILE *fp;
		char ch;
		char newch[1000];
		fp = fopen(fin, "r");
		int i = 0;
		while (1) {
			ch = fgetc(fp);
			newch[i] = ch;
			if (ch == EOF) {
				newch[i] = '\0';
				break;
			}
			i++;
		}
		printf(BLUE "Current Directory:" RESETCOLOR "\t");
		put_multiline(newch, 50);
		printf("\n");

		fclose(fp);
	} else {
		printf(BLUE "Current directory" RESETCOLOR "\thas no comment\n");
	}

	free(fin);
}