void ReadManifestFromPath()

in dotnet/tools/common/manifest.c [27:67]


void ReadManifestFromPath(const char *manifestPath)
{
    char buffer[64 * 1024];
    FILE *f;
    char *p;
    int line = 0;
    struct Entry *entry;

    /* read manifest file */
    f = fopen(manifestPath, "r");
    if (f == NULL)
    {
        p = getcwd(buffer, sizeof(buffer));
        printf("Can't open file MANIFEST in %s\n", p);
        exit(-1);
    }
    while (fgets(buffer, sizeof(buffer), f) != NULL)
    {
        ++line;
        p = strchr(buffer, '\n');
        if (p != NULL)
            *p = '\0';
        p = strchr(buffer, '\r');
        if (p != NULL)
            *p = '\0';

        p = strchr(buffer, ' ');
        if (p == NULL)
        {
            printf("Line %d is malformatted (no space)\n", line);
            exit(-1);
        }
        *p = '\0';
        entry = (struct Entry *)malloc(sizeof(struct Entry));
        entry->Key = strdup(buffer);
        entry->Path = strdup(p + 1);
        entry->Next = g_Entries;
        g_Entries = entry;
    }
    fclose(f);
}