CSS-Sass

 view release on metacpan or  search on metacpan

libsass/file.cpp  view on Meta::CPAN

        if (dwFileLength == INVALID_FILE_SIZE) return 0;
        // allocate an extra byte for the null char
        pBuffer = (BYTE*)malloc((dwFileLength+1)*sizeof(BYTE));
        ReadFile(hFile, pBuffer, dwFileLength, &dwBytes, NULL);
        pBuffer[dwFileLength] = '\0';
        CloseHandle(hFile);
        // just convert from unsigned char*
        char* contents = (char*) pBuffer;
      #else
        struct stat st;
        if (stat(path.c_str(), &st) == -1 || S_ISDIR(st.st_mode)) return 0;
        ifstream file(path.c_str(), ios::in | ios::binary | ios::ate);
        char* contents = 0;
        if (file.is_open()) {
          size_t size = file.tellg();
          // allocate an extra byte for the null char
          contents = (char*) malloc((size+1)*sizeof(char));
          file.seekg(0, ios::beg);
          file.read(contents, size);
          contents[size] = '\0';
          file.close();



( run in 0.648 second using v1.01-cache-2.11-cpan-49f99fa48dc )