| 213 | } |
| 214 | |
| 215 | func createSymlink(root, filePath string) error { |
| 216 | name := filepath.Base(filePath) |
| 217 | newname := filepath.Join(root, VirtenvBinPath, name) |
| 218 | |
| 219 | // Create bin path just in case it doesn't exist |
| 220 | if err := os.MkdirAll(filepath.Join(root, VirtenvBinPath), 0o755); err != nil { |
| 221 | return errors.WithStack(err) |
| 222 | } |
| 223 | |
| 224 | if _, err := os.Lstat(newname); err == nil { |
| 225 | if err = os.Remove(newname); err != nil { |
| 226 | return errors.WithStack(err) |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | return errors.WithStack(os.Symlink(filePath, newname)) |
| 231 | } |
| 232 | |
| 233 | func (m *Manager) shouldCreateFile( |
| 234 | pkg *lock.Package, |