(Path path, String fileName, String fileContent)
| 1551 | } |
| 1552 | |
| 1553 | private static void createTempFile(Path path, String fileName, String fileContent) { |
| 1554 | final int buffSize = fileContent.length() * 3; |
| 1555 | final long buffPtr = Unsafe.malloc(buffSize, MemoryTag.NATIVE_DEFAULT); |
| 1556 | final byte[] bytes = fileContent.getBytes(Files.UTF_8); |
| 1557 | long p = buffPtr; |
| 1558 | for (int i = 0, n = bytes.length; i < n; i++) { |
| 1559 | Unsafe.putByte(p++, bytes[i]); |
| 1560 | } |
| 1561 | Unsafe.putByte(p, (byte) 0); |
| 1562 | long fd = -1; |
| 1563 | try { |
| 1564 | fd = Files.openAppend(path.concat(fileName).$()); |
| 1565 | if (fd > -1) { |
| 1566 | Files.truncate(fd, 0); |
| 1567 | Files.append(fd, buffPtr, bytes.length); |
| 1568 | Files.sync(); |
| 1569 | } |
| 1570 | Assert.assertTrue(Files.exists(fd)); |
| 1571 | } finally { |
| 1572 | Files.close(fd); |
| 1573 | Unsafe.free(buffPtr, buffSize, MemoryTag.NATIVE_DEFAULT); |
| 1574 | } |
| 1575 | } |
| 1576 | |
| 1577 | private static void testAllocateConcurrent0(FilesFacade ff, String pathName, int index, AtomicInteger errors) { |
| 1578 | try ( |
no test coverage detected