GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — locks/client_local.go at master · asciimoth/locks

Expand file tree

/

client_local.go

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
61 lines (57 loc) · 1.4 KB
/

client_local.go

Copy path

File metadata and controls

61 lines (57 loc) · 1.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//go:build darwin || linux || openbsd || windows
package locks
import (
"context"
"errors"
"os"
"path/filepath"
)
// prepareParent creates missing directories without following links. Existing
// directories keep their permissions. The caller must trust the path's owners,
// as required for Local. Each new directory uses the local stage permissions.
func prepareParent(ctx context.Context, path string) error {
d, err := createParents(ctx, path)
if err != nil {
return err
}
return d.f.Close()
}
func createParents(ctx context.Context, path string) (*directory, error) {
var missing []string
var d *directory
for {
if err := ctx.Err(); err != nil {
return nil, err
}
var err error
d, err = openParent(ctx, path)
if err == nil {
break
}
parent := filepath.Dir(path)
if !errors.Is(err, os.ErrNotExist) || parent == path {
return nil, err
}
missing = append(missing, filepath.Base(path))
path = parent
}
for i := len(missing) - 1; i >= 0; i-- {
if err := ctx.Err(); err != nil {
return nil, errors.Join(err, d.f.Close())
}
child, err := d.createDir(missing[i])
if errors.Is(err, os.ErrExist) {
// Another writer can create this directory before us.
child, err = d.child(missing[i])
}
err = errors.Join(err, d.f.Close())
if err != nil {
if child != nil {
err = errors.Join(err, child.f.Close())
}
return nil, err
}
d = child
}
return d, nil
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.