# file.Find

- **Ortam:** İstemci, Sunucu, Menü
- **İngilizce aslı:** https://wiki.facepunch.com/gmod/file.Find
- **Çeviri tarihi:** 2025-09-08

```lua
table, table file.Find( string name, string path, string sorting = "nameasc" )
```

## Açıklama

Tek bir klasörün içindeki dosya ve dizinlerin bir listesini döndürür.

> **UYARI:** Görünüşe göre büyük harf içeren yollar (örneğin, `lua/MyFolder/*`) Linux'ta beklendiği gibi çalışmıyor.

## Argümanlar

1. [string](https://gmod.tr/wiki/string) **name**: Aranacak joker karakter. `models/*.mdl`, `models/` klasöründeki **.mdl** dosyalarını listeleyecektir.
2. [string](https://gmod.tr/wiki/string) **path**: Dosyaların ve dizinlerin aranacağı yol. Geçerli yolların bir listesi için [bu listeye](https://gmod.tr/wiki/File_Search_Paths) bakın.
3. [string](https://gmod.tr/wiki/string) **sorting** = "nameasc": Kullanılacak sıralama, **isteğe bağlıdır**. - `nameasc` dosyaları ada göre artan şekilde sıralar. - `namedesc` dosyaları ada göre azalan şekilde sıralar. - `dateasc` dosyaları tarihe göre artan şekilde sıralar. - `datedesc` dosyaları tarihe göre azalan şekilde sıralar.

## Dönen Değerler

1. [table](https://gmod.tr/wiki/table): Bulunan dosyaların bir tablosu veya yol geçersizse `nil`
2. [table](https://gmod.tr/wiki/table): Bulunan dizinlerin bir tablosu veya yol geçersizse `nil`

### Örnek

`data` klasöründeki ilk dosyayı ve ilk dizini yazdırır.

```lua
local files, directories = file.Find( "*", "DATA" )

print( "Dosya: " .. files[1], "Klasör: " .. directories[1] )
```

**Çıktı:**

```lua
Dosya: helloworld.txt
Klasör: ctp
```

### Örnek

Belirli bir eklentinin veya tüm eklentilerin içine doğrudan bakabilen, ilkel bir `whereis file` komutu. Belirli dosyaları bulmak için engine.GetAddons+eklenti başlıklarında özyinelemeli olarak arama yapar.

```lua
local function recurseListContents(path, addon, direct, pattern)
    local files, dirs = file.Find(path.."*", addon)
    local matchedFiles = {}

    for _, v in ipairs(files) do
        local fullPath = path..v
        if not pattern or string.match(fullPath, pattern) then
            table.insert(matchedFiles, fullPath)
        end
    end
    if direct then return matchedFiles end

    for _, dir in ipairs(dirs) do
        local subFiles = recurseListContents(path..dir.."/", addon, false, pattern)
        for _, file in ipairs(subFiles) do
            table.insert(matchedFiles, file)
        end
    end

    return matchedFiles
end

function FindContentInAddon(the_special_content, in_a_specific_addon)
    local addons = engine.GetAddons()

    if not the_special_content then
        for _, addon in ipairs(addons) do
            local title = addon.title
            print("\nİçerik listeleniyor:", title)
            recurseListContents("", title, false)
        end
        return
    end

    local found = {}
    for _, addon in ipairs(addons) do
        local title = in_a_specific_addon or addon.title
        local path = addon.file
        local pattern = the_special_content:gsub("%*", ".*")

        local files = recurseListContents("", title, false, pattern)
        if #files > 0 then
            table.insert(found, {title, files, path})
        end

        if in_a_specific_addon then break end
    end

    if #found > 0 then
        for _, v in ipairs(found) do
            local matches = #v[2]
            print(matches.." adet eşleşme \""..v[1].."\" eklentisinde bulundu, bağlama noktası: "..v[3])
            for _, filePath in ipairs(v[2]) do
                print(" - "..filePath)
            end
        end
    else
        if in_a_specific_addon then
            print(the_special_content.." şurada bulunamadı: "..in_a_specific_addon.."!")
        else
            print(" - "..the_special_content.." bulunamadı!")
        end
    end
end
concommand.Add("find_content", function(ply, cmd, args) FindContentInAddon(args[1], args[2]) end)
```

**Çıktı:**

```lua
] find_content *
	- tüm eklentilerdeki tüm içeriği listeler, joker karakterler desteklenir :)

] find_content *.lua
	2 adet eşleşme "Extended Spawnmenu" eklentisinde bulundu, bağlama noktası: content/4000/104603291/104603291.gma
		- lua/autorun/rb655_extended_spawnmenu.lua
		- lua/autorun/rb655_legacy_addon_props.lua
	9 adet eşleşme "Seamless Portals" eklentisinde bulundu, bağlama noktası: content/4000/2773737445/gmpublisher.gma
		- lua/autorun/sh_detours.lua
		- lua/autorun/sh_portal_movement.lua
		- lua/autorun/client/cl_render_core.lua
		- lua/autorun/server/sv_portals_pvs.lua
		- lua/autorun/server/sv_prop_teleport.lua
		- lua/entities/seamless_portal.lua
		- lua/weapons/portal_gun.lua
		- lua/weapons/gmod_tool/stools/portal_creator_tool.lua
		- lua/weapons/gmod_tool/stools/portal_resizer_tool.lua
	7 adet eşleşme "Track Assembly Tool" eklentisinde bulundu, bağlama noktası: content/4000/287012681/TrackAssemblyTool.gma
		- lua/autorun/trackassembly_init.lua
		- lua/autorun/z_autorun_[shinji85_s_rails].lua
		- lua/entities/gmod_wire_expression2/core/custom/cl_trackasmlib_wire.lua
		- lua/entities/gmod_wire_expression2/core/custom/trackasmlib_wire.lua
		- lua/trackassembly/trackasmlib.lua
		- lua/vgui/dasminsliderbutton.lua
		- lua/weapons/gmod_tool/stools/trackassembly.lua
	1 adet eşleşme "Collision Resizer (ENHANCED)" eklentisinde bulundu, bağlama noktası: cache/workshop/217376234.gma
		- lua/weapons/gmod_tool/stools/advresizer.lua
	4 adet eşleşme "Advanced Material | REBORN" eklentisinde bulundu, bağlama noktası: content/4000/3118788923/gmpublisher.gma
		- lua/autorun/sh_mateditor_loader.lua
		- lua/mateditor/sh_advmat_footsteps.lua
		- lua/mateditor/sh_mateditor.lua
		- lua/weapons/gmod_tool/stools/advmat.lua

] find_content m_anm.mdl
1 adet eşleşme "[wOS] Animation Extension - Base (Full Version)" eklentisinde bulundu, bağlama noktası: content/4000/757604550/wiltos_animation_base.gma
	- models/m_anm.mdl
```

- [GMod Wiki ana sayfası](https://gmod.tr/wiki)

---

[Tüm sunucular](https://gmod.tr/) · [GmodTR Launcher](https://gmod.tr/launcher) · [Rehber](https://gmod.tr/rehber) · [GMod Wiki](https://gmod.tr/wiki) · [GmodTR nedir?](https://gmod.tr/hakkinda) · [Sunucu ekle](https://gmod.tr/sunucu-ekle) · [Discord](https://discord.gg/gmodtr)

Kaynak: https://gmod.tr/wiki/file.Find
