summaryrefslogtreecommitdiff
path: root/mcmap/examples/delchunk
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2013-09-21 00:48:59 +0200
committerKevin Chabowski <kevin@kch42.de>2013-09-21 00:48:59 +0200
commitf051ce2392bc0bfae52945e8f53fe38f2d095637 (patch)
tree9cf7e28b009757747d12c5d4ac3e36a6469d4295 /mcmap/examples/delchunk
parentfc3743db98c3cc9f800cd50ae087e505ff260c0c (diff)
downloadgomcmap-f051ce2392bc0bfae52945e8f53fe38f2d095637.tar.gz
gomcmap-f051ce2392bc0bfae52945e8f53fe38f2d095637.tar.bz2
gomcmap-f051ce2392bc0bfae52945e8f53fe38f2d095637.zip
Deleting chunks implemented.
Diffstat (limited to 'mcmap/examples/delchunk')
-rw-r--r--mcmap/examples/delchunk/.gitignore1
-rw-r--r--mcmap/examples/delchunk/main.go41
2 files changed, 42 insertions, 0 deletions
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)
+ }
+}