forked from theupdateframework/python-tuf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_lock.py
More file actions
26 lines (21 loc) · 683 Bytes
/
file_lock.py
File metadata and controls
26 lines (21 loc) · 683 Bytes
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
# Copyright 2025, New York University and the TUF contributors
# SPDX-License-Identifier: MIT OR Apache-2.0
"""Platform-specific support for file locking
"""
import os
import sys
if sys.platform in ['win32']:
def create_lockfile(filename: str) -> str:
# Use the name of the file but create lockfile in %TEMP%.
fn = os.path.basename(filename)
lockfile = os.path.join(os.getenv("TEMP"), "tuf" + fn)
#try:
# with open(filename, "w+") as f:
# f.truncate(1)
# f.flush()
#except:
# pass
return lockfile
else:
def create_lockfile(filename: str) -> str:
return filename