Skip to content

Commit

Permalink
add helper functions for debuging
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadVatandoost committed Aug 7, 2021
1 parent 18f3304 commit 97cf835
Show file tree
Hide file tree
Showing 23 changed files with 51 additions and 14 deletions.
2 changes: 1 addition & 1 deletion crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/fanap-infra/fsEngine/internal/constants"

"github.com/fanap-infra/fsEngine/internal/blockAllocationMap"
"github.com/fanap-infra/fsEngine/pkg/blockAllocationMap"
"github.com/fanap-infra/fsEngine/pkg/virtualFile"
)

Expand Down
23 changes: 23 additions & 0 deletions helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package fsEngine

import (
"github.com/fanap-infra/fsEngine/pkg/blockAllocationMap"
"github.com/fanap-infra/fsEngine/pkg/fileIndex"
)

func (fse *FSEngine) GetFileList() []*fileIndex.File {
return fse.header.GetFilesList()
}

func (fse *FSEngine) GetFileBLM(id uint32) (*blockAllocationMap.BlockAllocationMap, error) {
fileInfo, err := fse.header.GetFileData(id)
if err != nil {
return nil, err
}
blm, err := blockAllocationMap.Open(fse.log, fse, fse.maxNumberOfBlocks, fileInfo.GetLastBlock(),
fileInfo.GetRMapBlocks())
if err != nil {
return nil, err
}
return blm, nil
}
2 changes: 1 addition & 1 deletion internal/Header/blm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package Header_
import (
"fmt"

"github.com/fanap-infra/fsEngine/internal/blockAllocationMap"
"github.com/fanap-infra/fsEngine/pkg/blockAllocationMap"
)

func (hfs *HFileSystem) updateBLM() error {
Expand Down
2 changes: 1 addition & 1 deletion internal/Header/crud.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package Header_

import "github.com/fanap-infra/fsEngine/internal/fileIndex"
import "github.com/fanap-infra/fsEngine/pkg/fileIndex"

func (hfs *HFileSystem) CheckIDExist(id uint32) bool {
return hfs.fileIndex.CheckFileExistWithLock(id)
Expand Down
6 changes: 5 additions & 1 deletion internal/Header/fileIndex.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"hash/crc32"

"github.com/fanap-infra/fsEngine/internal/fileIndex"
"github.com/fanap-infra/fsEngine/pkg/fileIndex"
)

func (hfs *HFileSystem) generateFileIndex() ([]byte, error) {
Expand Down Expand Up @@ -127,6 +127,10 @@ func (hfs *HFileSystem) UpdateFileOptionalData(fileId uint32, info []byte) error
return hfs.fileIndex.UpdateFileOptionalData(fileId, info)
}

func (hfs *HFileSystem) GetFilesList() []*fileIndex.File {
return hfs.fileIndex.GetFilesList()
}

//func (hfs *HFileSystem) GetFileOptionalData(fileId uint32) ([]byte, error) {
// return hfs.fileIndex.
//}
4 changes: 2 additions & 2 deletions internal/Header/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"os"
"time"

"github.com/fanap-infra/fsEngine/internal/blockAllocationMap"
"github.com/fanap-infra/fsEngine/internal/fileIndex"
"github.com/fanap-infra/fsEngine/pkg/blockAllocationMap"
"github.com/fanap-infra/fsEngine/pkg/fileIndex"

"github.com/fanap-infra/log"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/Header/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/fanap-infra/fsEngine/internal/constants"

"github.com/fanap-infra/fsEngine/internal/blockAllocationMap"
"github.com/fanap-infra/fsEngine/internal/fileIndex"
"github.com/fanap-infra/fsEngine/pkg/blockAllocationMap"
"github.com/fanap-infra/fsEngine/pkg/fileIndex"
"github.com/fanap-infra/fsEngine/pkg/utils"

"github.com/fanap-infra/log"
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions internal/fileIndex/fileIndex.go → pkg/fileIndex/fileIndex.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ func (i *FileIndex) UpdateFileOptionalData(fileId uint32, info []byte) error {
return nil
}

func (i *FileIndex) GetFilesList() []*File {
i.rwMux.Lock()
defer i.rwMux.Unlock()
var files []*File
for _, f := range i.table.Files {
files = append(files, f)
}
return files
}

//func (i *FileIndex) GetFileOptionalData(fileId uint32) ([]byte, error) {
// i.rwMux.Lock()
// defer i.rwMux.Unlock()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pkg/virtualFile/IO.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"fmt"

"github.com/fanap-infra/fsEngine/internal/blockAllocationMap"
"github.com/fanap-infra/fsEngine/pkg/blockAllocationMap"
errPackage "github.com/fanap-infra/fsEngine/pkg/errstring"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/virtualFile/IO_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"math/rand"
"testing"

"github.com/fanap-infra/fsEngine/internal/blockAllocationMap"
"github.com/fanap-infra/fsEngine/pkg/blockAllocationMap"
"github.com/fanap-infra/log"
"github.com/stretchr/testify/assert"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/virtualFile/provider.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package virtualFile

import (
"github.com/fanap-infra/fsEngine/internal/blockAllocationMap"
"github.com/fanap-infra/fsEngine/internal/fileIndex"
"github.com/fanap-infra/fsEngine/pkg/blockAllocationMap"
"github.com/fanap-infra/fsEngine/pkg/fileIndex"

"github.com/fanap-infra/log"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/virtualFile/virtualFile.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package virtualFile

import (
"github.com/fanap-infra/fsEngine/internal/blockAllocationMap"
"github.com/fanap-infra/fsEngine/pkg/blockAllocationMap"

"github.com/fanap-infra/log"
)
Expand Down
2 changes: 1 addition & 1 deletion vfInfo.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fsEngine

import (
"github.com/fanap-infra/fsEngine/internal/blockAllocationMap"
"github.com/fanap-infra/fsEngine/pkg/blockAllocationMap"
"github.com/fanap-infra/fsEngine/pkg/virtualFile"
)

Expand Down

0 comments on commit 97cf835

Please sign in to comment.