// File: /workspace/github_cpp_makefile_star2_O2/mh0fm4[P]SCDC/src/components/dataprov/dataprov_fs2.cc
// Function: scdc_dataset_fs2_store::do_cmd_ls(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, _scdc_dataset_inout_t*, _scdc_dataset_inout_t*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool do_cmd_ls(const string &params, scdc_dataset_input_t *input, scdc_dataset_output_t *output, scdc_result &result)
    {
      SCDC_TRACE("do_cmd_ls: '" << params << "'");

      SCDC_DATASET_OUTPUT_CLEAR_(output);

      scdc_dataprov_fs2 *dataprov_fs2 = static_cast<scdc_dataprov_fs2 *>(dataprov);

      if (admin || pwd.size() == 0)
      {
        SCDC_TRACE("do_cmd_ls: listing stores");

        string main_path;
        dataprov_fs2->do_full_path(0, main_path);

        SCDC_TRACE("do_cmd_ls: main_path: '" << main_path << "'");

        DIR *dir = opendir(main_path.c_str());

        if (!dir)
        {
          result = "opening directory failed";
          SCDC_FAIL(__func__ << ": opening directory '" << main_path << "' failed: << result");
          return false;
        }

        scdcint_t stores = dir_count_stores(dir);

        SCDC_DATASET_OUTPUT_PRINTF_(output, "%" scdcint_fmt "|", stores);

        rewinddir(dir);

        struct dirent *ent;

        while ((ent = readdir(dir)) != NULL)
        {
          if (ent->d_type == DT_DIR && has_prefix(ent->d_name, DIR_STORE_PREFIX))
          {
            SCDC_TRACE("store: '" << ent->d_name << "'");
            SCDC_DATASET_OUTPUT_PRINTF_APPEND_(output, "%s|", ent->d_name + strlen(DIR_STORE_PREFIX));
          }
        }

        closedir(dir);

      } else
      {
        SCDC_TRACE("do_cmd_ls: listing entries of store '" << pwd << "'");

        string store_path;
        dataprov_fs2->do_full_path(0, store_path);

        store_path += DIR_STORE_PREFIX + pwd + "/";

        SCDC_TRACE("do_cmd_ls: store_path: '" << store_path << "'");

        DIR *dir = opendir(store_path.c_str());

        if (!dir)
        {
          result = "opening directory failed";
          SCDC_FAIL(__func__ << ": opening directory '" << store_path << "' failed: " << result);
          return false;
        }

        scdcint_t entries = dir_count_entries(dir);

        SCDC_DATASET_OUTPUT_PRINTF_(output, "%" scdcint_fmt "|", entries);

        rewinddir(dir);

        struct dirent *ent;

        while ((ent = readdir(dir)) != NULL)
        {
          if (ent->d_type == DT_REG && has_prefix_suffix(ent->d_name, DIR_ENTRY_PREFIX, DIR_ENTRY_SUFFIX))
          {
            string entry_name = trim_prefix_suffix(ent->d_name, DIR_ENTRY_PREFIX, DIR_ENTRY_SUFFIX);

            /* FIXME */
            string entry_format;

            string entry_path = store_path + ent->d_name;
            scdcint_t entry_size = z_fs_get_file_size(entry_path.c_str());

            SCDC_TRACE("entry: name: '" << entry_name << "', format: '" << entry_format << "', size: " << entry_size);
            SCDC_DATASET_OUTPUT_PRINTF_APPEND_(output, "%s:%s:%" scdcint_fmt "|", entry_name.c_str(), entry_format.c_str(), entry_size);
          }
        }
      }

      return true;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, %r15
movq %rcx, %rbx
movq %rdi, %r14
testq %rcx, %rcx
je 0x3920a
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rbx)
movb $0x6e, 0x30(%rbx)
movups %xmm0, 0x38(%rbx)
movq 0x8(%r14), %rdi
cmpb $0x0, 0x6c(%r14)
jne 0x392ea
cmpq $0x0, 0x20(%r14)
je 0x392ea
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x28(%rsp), %rdx
xorl %esi, %esi
callq 0x3783e
addq $0x18, %r14
leaq 0x1a353(%rip), %rsi     # 0x5359f
leaq 0x48(%rsp), %rdi
movq %r14, %rdx
callq 0x19ae2
leaq 0x180ed(%rip), %rdx     # 0x5134d
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x1cb18
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xba90
leaq 0x8(%rsp), %rdi
callq 0xb230
leaq 0x48(%rsp), %rdi
callq 0xb230
movq 0x28(%rsp), %rdi
callq 0xb830
movq %rax, %r14
testq %rax, %rax
je 0x39544
xorl %r15d, %r15d
leaq 0x1a2fb(%rip), %r12     # 0x535ad
leaq 0x19204(%rip), %r13     # 0x524bd
movq %r14, %rdi
callq 0xb870
testq %rax, %rax
je 0x39443
cmpb $0x8, 0x12(%rax)
jne 0x392b9
addq $0x13, %rax
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1a8dc
movzbl %al, %eax
addq %rax, %r15
jmp 0x392b9
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x8(%rsp), %rdx
xorl %esi, %esi
callq 0x3783e
movq 0x8(%rsp), %rdi
callq 0xb830
movq %rax, %r14
testq %rax, %rax
je 0x393a0
movq %r14, %rdi
callq 0x37ed9
leaq 0x191ad(%rip), %rdx     # 0x524d9
xorl %edi, %edi
movq %rbx, %rsi
movq %rax, %rcx
xorl %eax, %eax
callq 0x246c4
movq %r14, %rdi
callq 0xb2b0
leaq 0x1a255(%rip), %r15     # 0x5359f
leaq 0x1a258(%rip), %r12     # 0x535a9
pushq $0x1
popq %rbp
movq %r14, %rdi
callq 0xb870
movq %rax, %r13
testq %rax, %rax
je 0x39393
cmpb $0x4, 0x12(%r13)
jne 0x39354
leaq 0x13(%r13), %rdi
movq %r15, %rsi
callq 0x1a96a
testb %al, %al
je 0x39354
addq $0x1c, %r13
movl %ebp, %edi
movq %rbx, %rsi
movq %r12, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x246c4
jmp 0x39354
movq %r14, %rdi
callq 0xb910
jmp 0x39439
leaq 0x1a1a2(%rip), %rsi     # 0x53549
movq %r15, %rdi
callq 0xba40
leaq 0x3c1ca(%rip), %rbx     # 0x75580
movq (%rbx), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x39439
addq $0x20, %rdi
callq 0xb800
movq (%rbx), %rax
movq 0x8(%rax), %rdi
leaq 0x17db1(%rip), %rsi     # 0x51188
callq 0xb520
leaq 0x1a17f(%rip), %rsi     # 0x53562
movq %rax, %rdi
callq 0xb520
leaq 0x18a04(%rip), %rsi     # 0x51df6
movq %rax, %rdi
callq 0xb520
leaq 0x1a174(%rip), %rsi     # 0x53575
movq %rax, %rdi
callq 0xb520
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0xb490
leaq 0x1a16e(%rip), %rsi     # 0x5358b
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
callq 0xb270
movq (%rbx), %rdi
addq $0x20, %rdi
callq 0xb3e0
leaq 0x8(%rsp), %rdi
jmp 0x395f1
leaq 0x1908f(%rip), %rdx     # 0x524d9
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
xorl %eax, %eax
callq 0x246c4
movq %r14, %rdi
callq 0xb2b0
leaq 0x8(%rsp), %r13
leaq 0x68(%rsp), %rbp
leaq 0x48(%rsp), %r15
movq %r14, %rdi
callq 0xb870
movq %rax, %r12
testq %rax, %rax
je 0x395ec
cmpb $0x8, 0x12(%r12)
jne 0x39470
addq $0x13, %r12
movq %r12, %rdi
leaq 0x1a113(%rip), %rsi     # 0x535ad
leaq 0x1901c(%rip), %rdx     # 0x524bd
callq 0x1a8dc
testb %al, %al
je 0x39470
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x1a132
movq 0x10(%rsp), %rcx
addq $-0x9, %rcx
movq %r15, %rdi
movq %r13, %rsi
pushq $0x9
popq %rdx
callq 0xb560
movq %r13, %rdi
callq 0xb230
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
andq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movq %rbp, %rdi
leaq 0x28(%rsp), %rsi
movq %r12, %rdx
callq 0x1d867
movq 0x68(%rsp), %rdi
callq 0x2d9de
movq 0x48(%rsp), %rcx
movq 0x8(%rsp), %r8
pushq $0x1
popq %rdi
movq %rbx, %rsi
leaq 0x1a09a(%rip), %rdx     # 0x535b7
movq %rax, %r9
xorl %eax, %eax
callq 0x246c4
movq %rbp, %rdi
callq 0xb230
movq %r13, %rdi
callq 0xb230
movq %r15, %rdi
callq 0xb230
jmp 0x39470
leaq 0x19ffe(%rip), %rsi     # 0x53549
movq %r15, %rdi
callq 0xba40
leaq 0x3c026(%rip), %rbx     # 0x75580
movq (%rbx), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x395ec
addq $0x20, %rdi
callq 0xb800
movq (%rbx), %rax
movq 0x8(%rax), %rdi
leaq 0x17c09(%rip), %rsi     # 0x51188
callq 0xb520
leaq 0x19fd7(%rip), %rsi     # 0x53562
movq %rax, %rdi
callq 0xb520
leaq 0x1885c(%rip), %rsi     # 0x51df6
movq %rax, %rdi
callq 0xb520
leaq 0x19fcc(%rip), %rsi     # 0x53575
movq %rax, %rdi
callq 0xb520
leaq 0x28(%rsp), %rsi
movq %rax, %rdi
callq 0xb490
leaq 0x183e0(%rip), %rsi     # 0x519a5
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
movq %r15, %rsi
callq 0xb490
movq %rax, %rdi
callq 0xb270
movq (%rbx), %rdi
addq $0x20, %rdi
callq 0xb3e0
leaq 0x28(%rsp), %rdi
callq 0xb230
testq %r14, %r14
je 0x395ff
movb $0x1, %al
jmp 0x39601
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x39660
jmp 0x39660
jmp 0x3962c
movq %rax, %rbx
jmp 0x39652
jmp 0x39660
jmp 0x39660
jmp 0x3966a
jmp 0x39660
jmp 0x3966a
jmp 0x3966a
jmp 0x39660
movq %rax, %rbx
jmp 0x39648
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
jmp 0x39657
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xb230
leaq 0x8(%rsp), %rdi
callq 0xb230
leaq 0x48(%rsp), %rdi
callq 0xb230
jmp 0x39663
jmp 0x39660
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x39672
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xb230
movq %rbx, %rdi
callq 0xb9a0
nop