mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: migrating to electron-vite
This commit is contained in:
commit
1db5a9c295
183 changed files with 18535 additions and 0 deletions
32
torrent-client/fifo.py
Normal file
32
torrent-client/fifo.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
import platform
|
||||
|
||||
class Fifo:
|
||||
socket_handle = None
|
||||
|
||||
def __init__(self, path: str):
|
||||
if platform.system() == "Windows":
|
||||
import win32file
|
||||
|
||||
self.socket_handle = win32file.CreateFile(path, win32file.GENERIC_READ | win32file.GENERIC_WRITE,
|
||||
0, None, win32file.OPEN_EXISTING, win32file.FILE_ATTRIBUTE_NORMAL, None)
|
||||
else:
|
||||
import socket
|
||||
self.socket_handle = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
self.socket_handle.connect(path)
|
||||
|
||||
def recv(self, bufSize: int):
|
||||
if platform.system() == "Windows":
|
||||
import win32file
|
||||
|
||||
result, data = win32file.ReadFile(self.socket_handle, bufSize)
|
||||
return data
|
||||
else:
|
||||
return self.socket_handle.recv(bufSize)
|
||||
|
||||
def send_message(self, msg: str):
|
||||
if platform.system() == "Windows":
|
||||
import win32file
|
||||
|
||||
win32file.WriteFile(self.socket_handle, bytes(msg, "utf-8"))
|
||||
else:
|
||||
self.socket_handle.send(bytes(msg, "utf-8"))
|
Loading…
Add table
Add a link
Reference in a new issue