From f051ce2392bc0bfae52945e8f53fe38f2d095637 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Sat, 21 Sep 2013 00:48:59 +0200 Subject: Deleting chunks implemented. --- mcmap/examples/delchunk/.gitignore | 1 + mcmap/examples/delchunk/main.go | 41 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 mcmap/examples/delchunk/.gitignore create mode 100644 mcmap/examples/delchunk/main.go (limited to 'mcmap/examples/delchunk') diff --git a/mcmap/examples/delchunk/.gitignore b/mcmap/examples/delchunk/.gitignore new file mode 100644 index 0000000..732afb9 --- /dev/null +++ b/mcmap/examples/delchunk/.gitignore @@ -0,0 +1 @@ +delchunk diff --git a/mcmap/examples/delchunk/main.go b/mcmap/examples/delchunk/main.go new file mode 100644 index 0000000..c8996a5 --- /dev/null +++ b/mcmap/examples/delchunk/main.go @@ -0,0 +1,41 @@ +package main + +import ( + "flag" + "fmt" + "github.com/kch42/gomcmap/mcmap" + "os" +) + +func main() { + path := flag.String("path", "", "Path to region directory") + flag.Parse() + + if *path == "" { + flag.Usage() + os.Exit(1) + } + + region, err := mcmap.OpenRegion(*path, false) + if err != nil { + fmt.Fprintf(os.Stderr, "Could not open region: %s\n", err) + os.Exit(1) + } + + chunk, err := region.Chunk(200, 200) + if err != nil { + fmt.Fprintf(os.Stderr, "Error getting chunk 200,200: %s\n", err) + os.Exit(1) + } + + chunk.MarkDeleted() + if err := chunk.MarkUnused(); err != nil { + fmt.Fprintf(os.Stderr, "Could not mark chunk as unused: %s\n", err) + os.Exit(1) + } + + if err := region.Save(); err != nil { + fmt.Fprintf(os.Stderr, "Could not save region: %s\n", err) + os.Exit(1) + } +} -- cgit v1.2.3-70-g09d2