Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Function to List Hidden Files in a Directory #75

Open
hbisneto opened this issue Sep 29, 2024 · 0 comments
Open

Create a Function to List Hidden Files in a Directory #75

hbisneto opened this issue Sep 29, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@hbisneto
Copy link
Owner

Description:

Develop a Python function that lists all hidden files in a specified directory. The function should be compatible with Windows, Linux, and macOS operating systems.

Requirements:

  1. Function Name: get_hidden_files
  2. Parameters:
    • directory (str): The path to the directory where hidden files need to be listed.
  3. Returns:
    • A list of hidden files in the specified directory.

Specifications:

  • The function should use the os module to interact with the file system.
  • For Windows, hidden files are identified by the FILE_ATTRIBUTE_HIDDEN attribute.
  • For Linux and macOS, hidden files are identified by a leading dot (.) in the filename.
  • The function should handle exceptions gracefully, such as invalid directory paths or permission errors.

Example Usage:

from filesystem import file as fsfile
hidden_files = fsfile.get_hidden_files('/path/to/directory')
print(hidden_files)

Implementation Hints:

  • Use file.get_files() to list all files in the directory.
  • For Windows, consider using the ctypes library to check file attributes.

Additional Notes:

  • Ensure the function is well-documented with comments explaining each step.
  • Write unit tests to verify the function works correctly on all three operating systems.
@hbisneto hbisneto added the enhancement New feature or request label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant