<commit_before>%% ===================================================================
%% @author <NAME>
%% @copyright (C): 2013, ACK CYFRONET AGH
%% This software is released under the MIT license 
%% cited in 'LICENSE.txt'.
%% @end
%% ===================================================================
%% @doc: This module provides set of path processing methods.
%% @end
%% ===================================================================
-module(fslogic_path).
-author("<NAME>").

-include("veil_modules/dao/dao.hrl").
-include("veil_modules/fslogic/fslogic.hrl").
-include("logging.hrl").

%% API
-export([get_user_file_name/1, get_user_file_name/2]).
-export([get_full_file_name/1, get_full_file_name/2, get_full_file_name/4]).
-export([verify_file_name/1]).
-export([strip_path_leaf/1, basename/1]).
-export([get_parent_and_name_from_path/2]).
-export([get_user_root/0, get_user_root/2, get_user_root/1]).

%% ====================================================================
%% API functions
%% ====================================================================

get_user_file_name(FullFileName) ->
    {_, UserDoc} = fslogic_objects:get_user(),
    get_user_file_name(FullFileName, UserDoc).

get_user_file_name(FullFileName, UserDoc) ->
    {ok, Tokens} = verify_file_name(FullFileName),

    UserRec = dao_lib:strip_wrappers(UserDoc),
    UserName = UserRec#user.login,

    case Tokens of
        [UserName | UserTokens] -> "/" ++ string:join(UserTokens, "/");
        _ -> "/" ++ string:join(Tokens, "/")
    end.<commit_msg>VFS-553: fslogic_path docs<commit_after>%% ===================================================================
%% @author <NAME>
%% @copyright (C): 2013, ACK CYFRONET AGH
%% This software is released under the MIT license 
%% cited in 'LICENSE.txt'.
%% @end
%% ===================================================================
%% @doc: This module provides set of path processing methods.
%% @end
%% ===================================================================
-module(fslogic_path).
-author("<NAME>").

-include("veil_modules/dao/dao.hrl").
-include("veil_modules/fslogic/fslogic.hrl").
-include("logging.hrl").

%% API
-export([get_user_file_name/1, get_user_file_name/2]).
-export([get_full_file_name/1, get_full_file_name/2, get_full_file_name/4]).
-export([verify_file_name/1]).
-export([strip_path_leaf/1, basename/1]).
-export([get_parent_and_name_from_path/2]).
-export([get_user_root/0, get_user_root/2, get_user_root/1]).

%% ====================================================================
%% API functions
%% ====================================================================

%% get_user_file_name/1
%% ====================================================================
%% @doc Gets user's file name. This method reverses get_full_file_name.
%%      Throws on error (e.g. file path was invalid). <br/>
%%      Note: this method requires user context! Without it you'll get input path.
%% @end
-spec get_user_file_name(FullFileName :: string()) -> Result when
    Result :: UserFileName :: string() | no_return().
%% ====================================================================
get_user_file_name(FullFileName) ->
    {_, UserDoc} = fslogic_objects:get_user(),
    get_user_file_name(FullFileName, UserDoc).

get_user_file_name(FullFileName, UserDoc) ->
    {ok, Tokens} = verify_file_name(FullFileName),

    UserRec = dao_lib:strip_wrappers(UserDoc),
    UserName = UserRec#user.login,

    case Tokens of
        [UserName | UserTokens] -> "/" ++ string:join(UserTokens, "/");
        _ -> "/" ++ string:join(Tokens, "/")
    end.
{'fraction_non_alphanumeric': 0.3542588495575221, 'fraction_numerical': 0.00995575221238938, 'mean_word_length': 6.064453125, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7308572', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1045, 'n_words': 188}