Beispiel #1
0
DDR_RC
readFileList(OMRPortLibrary *portLibrary, const char *debugFileList, vector<string> *debugFiles)
{
	OMRPORT_ACCESS_FROM_OMRPORT(portLibrary);
	DDR_RC rc = DDR_RC_OK;

	/* Read list of debug files to scan from the input file. */
	intptr_t fd = omrfile_open(debugFileList,  EsOpenRead, 0660);
	if (0 > fd) {
		ERRMSG("Failure attempting to open %s\nExiting...\n", debugFileList);
		rc = DDR_RC_ERROR;
	} else {
		char *buff = NULL;
		int64_t offset = omrfile_seek(fd, 0, SEEK_END);
		if (-1 != offset) {
			buff = (char *)malloc(offset + 1);
			memset(buff, 0, offset + 1);
			omrfile_seek(fd, 0, SEEK_SET);

			if (0 < omrfile_read(fd, buff, offset)) {
				char *fileName = strtok(buff, "\n");
				while (NULL != fileName) {
					debugFiles->push_back(string(fileName));
					fileName = strtok(NULL, "\n");
				}
			}
			free(buff);
		}
	}
	return rc;
}
Beispiel #2
0
int32_t
omrfile_set_length(struct OMRPortLibrary *portLibrary, intptr_t fd, int64_t newLength)
{
	int32_t lastError = 0;
	int64_t currentFilePtr = 0;

	Trc_PRT_file_setlength_Entry(fd, newLength);

	/* Save current file pointer location */
	currentFilePtr = omrfile_seek(portLibrary, fd, 0, EsSeekCur);

	if ((-1 != currentFilePtr) && (-1 != omrfile_seek(portLibrary, fd, newLength, FILE_BEGIN))) {
		if (0 == SetEndOfFile((HANDLE)fd)) {
			lastError = GetLastError();
			lastError =  portLibrary->error_set_last_error(portLibrary, lastError, findError(lastError));
			Trc_PRT_file_setlength_Exit(lastError);
			return lastError;
		}

		/* Put pointer back to where it started */
		if (-1 != omrfile_seek(portLibrary, fd, currentFilePtr, EsSeekSet)) {
			Trc_PRT_file_setlength_Exit(0);
			return 0;
		}
	}

	/* omrfile_seek already set the last error */
	lastError = portLibrary->error_last_error_number(portLibrary);
	Trc_PRT_file_setlength_Exit(lastError);
	return lastError;
}