{"id":26826714,"url":"https://github.com/hslam/copyfilerange","last_synced_at":"2025-03-30T11:30:44.659Z","repository":{"id":207249146,"uuid":"718778710","full_name":"hslam/copyfilerange","owner":"hslam","description":"Package copyfilerange wraps the copy_file_range system call.","archived":false,"fork":false,"pushed_at":"2023-11-14T20:31:40.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-11-16T10:01:21.229Z","etag":null,"topics":["copy-file-range","copyfilerange","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hslam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-11-14T19:30:54.000Z","updated_at":"2023-11-14T20:38:01.000Z","dependencies_parsed_at":"2023-11-14T21:25:54.905Z","dependency_job_id":"4f30d00d-ef7c-44a3-905f-818d41705cbf","html_url":"https://github.com/hslam/copyfilerange","commit_stats":null,"previous_names":["hslam/copyfilerange"],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fcopyfilerange","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fcopyfilerange/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fcopyfilerange/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fcopyfilerange/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hslam","download_url":"https://codeload.github.com/hslam/copyfilerange/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246313654,"owners_count":20757446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["copy-file-range","copyfilerange","go","golang"],"created_at":"2025-03-30T11:30:44.108Z","updated_at":"2025-03-30T11:30:44.639Z","avatar_url":"https://github.com/hslam.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# copyfilerange\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/hslam/copyfilerange)](https://pkg.go.dev/github.com/hslam/copyfilerange)\n[![Build Status](https://github.com/hslam/copyfilerange/workflows/build/badge.svg)](https://github.com/hslam/copyfilerange/actions)\n[![codecov](https://codecov.io/gh/hslam/copyfilerange/branch/master/graph/badge.svg)](https://codecov.io/gh/hslam/copyfilerange)\n[![Go Report Card](https://goreportcard.com/badge/github.com/hslam/copyfilerange)](https://goreportcard.com/report/github.com/hslam/copyfilerange)\n[![LICENSE](https://img.shields.io/github/license/hslam/copyfilerange.svg?style=flat-square)](https://github.com/hslam/copyfilerange/blob/master/LICENSE)\n\nPackage copyfilerange wraps the copy_file_range system call.\n\n## Get started\n\n### Install\n```\ngo get github.com/hslam/copyfilerange\n```\n### Import\n```\nimport \"github.com/hslam/copyfilerange\"\n```\n### Usage\n#### Example\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/hslam/copyfilerange\"\n\t\"os\"\n)\n\nfunc main() {\n\tsrcName, dstName := \"srcFile\", \"dstFile\"\n\tsrcFile, _ := os.Create(srcName)\n\tdefer os.Remove(srcName)\n\tdefer srcFile.Close()\n\tdstFile, _ := os.Create(dstName)\n\tdefer os.Remove(dstName)\n\tdefer dstFile.Close()\n\n\tcontent := []byte(\"Hello world\")\n\tsrcOffset, dstOffset := int64(64), int64(32)\n\tsrcFile.Truncate(srcOffset)\n\tsrcFile.WriteAt(content, srcOffset)\n\tdstFile.Truncate(dstOffset + int64(len(content)))\n\n\troff, woff := srcOffset, dstOffset\n\tcopyfilerange.CopyFileRange(int(srcFile.Fd()), \u0026roff, int(dstFile.Fd()), \u0026woff, len(content), 0)\n\n\tbuf := make([]byte, len(content))\n\tdstFile.ReadAt(buf, dstOffset)\n\tfmt.Println(string(buf))\n}\n```\n\n### Output\n```\nHello world\n```\n\n### License\nThis package is licensed under a MIT license (Copyright (c) 2023 Meng Huang)\n\n\n### Author\ncopyfilerange was written by Meng Huang.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhslam%2Fcopyfilerange","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhslam%2Fcopyfilerange","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhslam%2Fcopyfilerange/lists"}